Do not add query to history if it was the last

Maybe people just press enter twice.

This is the behaviour of bash.
master
Salvo 'LtWorf' Tomaselli 2016-01-03 17:32:34 +07:00
parent 1dd1298ee0
commit 5563e1cafd
1 changed files with 9 additions and 5 deletions

@ -190,11 +190,15 @@ class relForm(QtWidgets.QMainWindow):
self.showRelation(self.selectedRelation)
if not self.multiline:
# Adds to history
hitem = QtWidgets.QListWidgetItem(None, 0)
hitem.setText(query)
self.ui.lstHistory.addItem(hitem)
self.ui.lstHistory.setCurrentItem(hitem)
# Last in history
item = self.ui.lstHistory.item(self.ui.lstHistory.count() - 1)
if item is None or item.text() != query:
# Adds to history if it is not already the last
hitem = QtWidgets.QListWidgetItem(None, 0)
hitem.setText(query)
self.ui.lstHistory.addItem(hitem)
self.ui.lstHistory.setCurrentItem(hitem)
finally:
# Restore the normal frame
self.setMultiline(self.multiline)