When calling the active tab idx setter do not re-record the current tab in the active tab history if the current tab will not actually change. Fixes #3871

This commit is contained in:
Kovid Goyal
2021-07-27 09:12:35 +05:30
parent 1bd39ff935
commit 9c9d68561e

View File

@@ -625,6 +625,9 @@ class TabManager: # {{{
@active_tab_idx.setter
def active_tab_idx(self, val: int) -> None:
new_active_tab_idx = max(0, min(val, len(self.tabs) - 1))
if new_active_tab_idx == self._active_tab_idx:
return
try:
old_active_tab: Optional[Tab] = self.tabs[self._active_tab_idx]
except Exception:
@@ -632,7 +635,7 @@ class TabManager: # {{{
else:
assert old_active_tab is not None
add_active_id_to_history(self.active_tab_history, old_active_tab.id)
self._active_tab_idx = max(0, min(val, len(self.tabs) - 1))
self._active_tab_idx = new_active_tab_idx
try:
new_active_tab: Optional[Tab] = self.tabs[self._active_tab_idx]
except Exception: