Forgot to restore current index before restoring current_id/current_row which was preventing the current column from being preserved

This commit is contained in:
Kovid Goyal 2023-04-26 14:09:55 +05:30
parent ef13a51774
commit 2a58a4b1a8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -162,6 +162,7 @@ class PreserveViewState: # {{{
self.current_id = None
self.vscroll = self.hscroll = 0
self.original_view = None
self.row = self.col = -1
def __enter__(self):
self.init_vals()
@ -171,11 +172,16 @@ class PreserveViewState: # {{{
self.current_id = self.view.current_id
self.vscroll = view.verticalScrollBar().value()
self.hscroll = view.horizontalScrollBar().value()
ci = self.view.currentIndex()
self.row, self.col = ci.row(), ci.column()
except:
import traceback
traceback.print_exc()
def __exit__(self, *args):
ci = self.view.model().index(self.row, self.col)
if ci.isValid():
self.view.setCurrentIndex(ci)
if self.selected_ids or not self.require_selected_ids:
if self.current_id is not None:
self.view.current_id = self.current_id