diff --git a/kitty/boss.py b/kitty/boss.py index 750d6bb4b..fd62035b2 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -182,7 +182,7 @@ class VisualSelect: if self.window_used_for_selection_id: w = boss.window_id_map.get(self.window_used_for_selection_id) if w is not None: - boss.close_window(w) + boss.mark_window_for_close(w) return boss @@ -585,11 +585,15 @@ class Boss: if window is not None: window.focus_changed(True) - def close_window(self, window: Optional[Window] = None) -> None: + def mark_window_for_close(self, window: Optional[Window] = None) -> None: window = window or self.active_window if window: self.child_monitor.mark_for_close(window.id) + @ac('win', 'Close the currently active window') + def close_window(self) -> None: + self.mark_window_for_close() + @ac('tab', 'Close the current tab') def close_tab(self, tab: Optional[Tab] = None) -> None: tab = tab or self.active_tab @@ -626,7 +630,7 @@ class Boss: def close_tab_no_confirm(self, tab: Tab) -> None: for window in tab: - self.close_window(window) + self.mark_window_for_close(window) @ac('win', 'Toggle the fullscreen status of the active OS Window') def toggle_fullscreen(self, os_window_id: int = 0) -> None: diff --git a/kitty/rc/close_window.py b/kitty/rc/close_window.py index 8603e8e2f..a63634f15 100644 --- a/kitty/rc/close_window.py +++ b/kitty/rc/close_window.py @@ -33,7 +33,7 @@ If specified close the window this command is run in, rather than the active win def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType: for window in self.windows_for_match_payload(boss, window, payload_get): if window: - boss.close_window(window) + boss.mark_window_for_close(window) return None diff --git a/kitty/tabs.py b/kitty/tabs.py index 8e785b09a..f2fa8b6ca 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -456,12 +456,6 @@ class Tab: # {{{ allow_remote_control=allow_remote_control, watchers=special_window.watchers ) - @ac('win', 'Close the currently active window') - def close_window(self) -> None: - w = self.active_window - if w is not None: - self.remove_window(w) - @ac('win', 'Close all windows in the tab other than the currently active window') def close_other_windows_in_tab(self) -> None: if len(self.windows) > 1: diff --git a/kitty/window.py b/kitty/window.py index 663cdd832..231ba0a18 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -577,7 +577,7 @@ class Window: return g.left <= x <= g.right and g.top <= y <= g.bottom def close(self) -> None: - get_boss().close_window(self) + get_boss().mark_window_for_close(self) @ac('misc', ''' Send the specified text to the active window