when an existing search term is reused, move it to top

This commit is contained in:
Damien Elmes 2012-12-20 18:51:57 +09:00
parent 42f8088037
commit 1a5fd5c44a

View file

@ -475,9 +475,11 @@ class Browser(QMainWindow):
def onSearch(self, reset=True): def onSearch(self, reset=True):
"Careful: if reset is true, the current note is saved." "Careful: if reset is true, the current note is saved."
txt = unicode(self.form.searchEdit.lineEdit().text()).strip() txt = unicode(self.form.searchEdit.lineEdit().text()).strip()
sh = self.mw.pm.profile['searchHistory']
prompt = _("<type here to search; hit enter to show current deck>") prompt = _("<type here to search; hit enter to show current deck>")
if txt not in sh: sh = self.mw.pm.profile['searchHistory']
# update search history
if txt in sh:
sh.remove(txt)
sh.insert(0, txt) sh.insert(0, txt)
sh = sh[:30] sh = sh[:30]
self.form.searchEdit.clear() self.form.searchEdit.clear()