From 5563e1cafd413df3b4e53cfe91c8e724cbdd1a0a Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sun, 3 Jan 2016 17:32:34 +0100 Subject: [PATCH] Do not add query to history if it was the last Maybe people just press enter twice. This is the behaviour of bash. --- relational_gui/guihandler.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/relational_gui/guihandler.py b/relational_gui/guihandler.py index d1663a5..9bb8850 100644 --- a/relational_gui/guihandler.py +++ b/relational_gui/guihandler.py @@ -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)