From 1a5fd5c44a67309bb478b76512dfe51f95bfef4b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 20 Dec 2012 18:51:57 +0900 Subject: [PATCH] when an existing search term is reused, move it to top --- aqt/browser.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/aqt/browser.py b/aqt/browser.py index 98b0930e4..9479e05d4 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -475,14 +475,16 @@ class Browser(QMainWindow): def onSearch(self, reset=True): "Careful: if reset is true, the current note is saved." txt = unicode(self.form.searchEdit.lineEdit().text()).strip() - sh = self.mw.pm.profile['searchHistory'] prompt = _("") - if txt not in sh: - sh.insert(0, txt) - sh = sh[:30] - self.form.searchEdit.clear() - self.form.searchEdit.addItems(sh) - self.mw.pm.profile['searchHistory'] = sh + sh = self.mw.pm.profile['searchHistory'] + # update search history + if txt in sh: + sh.remove(txt) + sh.insert(0, txt) + sh = sh[:30] + self.form.searchEdit.clear() + self.form.searchEdit.addItems(sh) + self.mw.pm.profile['searchHistory'] = sh if self.mw.state == "review" and "is:current" in txt: # search for current card, but set search to easily display whole # deck