From e98f80d836cf189f12d4dab91382b29313f712e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 07:26:45 +0000 Subject: [PATCH] Prevent multiple stacking Rename tab overlay windows Fixes #9691 Fixes #9692 --- kitty/boss.py | 20 ++++++++++++++++---- kitty/tabs.py | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index 0d8034baf..956aa2362 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1237,7 +1237,7 @@ def get_line( is_password: bool = False, initial_value: str = '', window_title: str = '', - ) -> None: + ) -> Window | None: result: str = '' def callback_(res: dict[str, Any], x: int, boss: Boss) -> None: @@ -1252,7 +1252,7 @@ def on_popup_overlay_removal(wid: int, boss: Boss) -> None: cmd.append('--default=' + initial_value) if window_title: cmd.append(f'--title={window_title}') - self.run_kitten_with_metadata( + return self.run_kitten_with_metadata( 'ask', cmd, window=window, custom_callback=callback_, default_data={'response': ''}, action_on_removal=on_popup_overlay_removal ) @@ -2377,12 +2377,24 @@ def set_tab_title(self, title: str | None = None) -> None: title = '' tab.set_title(title) return + if tab.renaming_in_window and tab.renaming_in_window in self.window_id_map: + w = self.window_id_map[tab.renaming_in_window] + if w in tab: + tab.set_active_window(w) + return prefilled = tab.name or tab.title if title in ('" "', "' '"): prefilled = '' - self.get_line( + + def on_rename_done(new_title: str) -> None: + tab.renaming_in_window = 0 + tab.set_title(new_title) + + overlay_window = self.get_line( _('Enter the new title for this tab below. An empty title will cause the default title to be used.'), - tab.set_title, window=tab.active_window, initial_value=prefilled, window_title=_('Rename tab')) + on_rename_done, window=tab.active_window, initial_value=prefilled, window_title=_('Rename tab')) + if overlay_window is not None: + tab.renaming_in_window = overlay_window.id def create_special_window_for_show_error(self, title: str, msg: str, overlay_for: int | None = None) -> SpecialWindowInstance: ec = sys.exc_info() diff --git a/kitty/tabs.py b/kitty/tabs.py index 720f3f4cc..f3ee9e4cb 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -145,6 +145,7 @@ class Tab: # {{{ inactive_fg: int | None = None inactive_bg: int | None = None confirm_close_window_id: int = 0 + renaming_in_window: int = 0 num_of_windows_with_progress: int = 0 total_progress: int = 0 has_indeterminate_progress: bool = False