From f2734fcfbd19522e3c72977f29fc2efaa6512d5a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 17 Mar 2026 13:39:07 +0530 Subject: [PATCH] Cleanup copilot code --- docs/changelog.rst | 2 ++ kitty/boss.py | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index cdf0229d1..a18ee4512 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -176,6 +176,8 @@ Detailed list of changes - Fix incorrect behavior when using the actions to move tab forward/backward with a tab_bar_filter active (:iss:`9672`) +- Prevent stacking of multiple rename tab windows (:iss:`9691`) + 0.46.1 [2026-03-16] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/boss.py b/kitty/boss.py index 956aa2362..74d556d24 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1252,9 +1252,10 @@ class Boss: cmd.append('--default=' + initial_value) if window_title: cmd.append(f'--title={window_title}') - return self.run_kitten_with_metadata( + w = self.run_kitten_with_metadata( 'ask', cmd, window=window, custom_callback=callback_, default_data={'response': ''}, action_on_removal=on_popup_overlay_removal ) + return w if isinstance(w, Window) else None def get_save_filepath( self, msg: str, # can contain newlines and ANSI formatting @@ -2377,18 +2378,16 @@ class Boss: 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 = '' + if (w := self.window_id_map.get(tab.renaming_in_window)) is not None and w in tab: + tab.set_active_window(w) + return + prefilled = (tab.name or tab.title).strip() + tab_id = tab.id def on_rename_done(new_title: str) -> None: - tab.renaming_in_window = 0 - tab.set_title(new_title) + if (tab := self.tab_for_id(tab_id)) is not 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.'),