From 9c9d68561e5a97cafa67817dcc5ac67c5a85bc24 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Jul 2021 09:12:35 +0530 Subject: [PATCH] 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 --- kitty/tabs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kitty/tabs.py b/kitty/tabs.py index b4cc6e4ab..53d9a2ffb 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -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: