From c050833aba02a1e75c4987bacee7f6f6491d8688 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 1 Apr 2020 11:01:20 +1000 Subject: [PATCH] always position selection in center after search https://anki.tenderapp.com/discussions/beta-testing/1888-retaining-position-when-searching --- qt/aqt/browser.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index 1e7ed424c..fb1bdb1e3 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -261,13 +261,11 @@ class DataModel(QAbstractTableModel): tv = self.browser.form.tableView if idx: tv.selectRow(idx.row()) - # scroll if the selection count has changed - if count != len(self.selectedCards): - # we save and then restore the horizontal scroll position because - # scrollTo() also scrolls horizontally which is confusing - h = tv.horizontalScrollBar().value() - tv.scrollTo(idx, tv.PositionAtCenter) - tv.horizontalScrollBar().setValue(h) + # we save and then restore the horizontal scroll position because + # scrollTo() also scrolls horizontally which is confusing + h = tv.horizontalScrollBar().value() + tv.scrollTo(idx, tv.PositionAtCenter) + tv.horizontalScrollBar().setValue(h) if count < 500: # discard large selections; they're too slow sm.select(