Add a new mappable action `close_other_windows_in_tab` to close all but the active window

Fixes #2484
This commit is contained in:
Kovid Goyal 2020-03-26 22:05:00 +05:30
parent 8f1c6c4d74
commit 93a281c7e3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 16 additions and 0 deletions

View File

@ -10,6 +10,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Fix a regression in 0.17 that broke drawing of borders with non-minimal - Fix a regression in 0.17 that broke drawing of borders with non-minimal
borders (:iss:`2474`) borders (:iss:`2474`)
- Add a new mappable action ``close_other_windows_in_tab`` to close all but the
active window (:iss:`2484`)
- Hints kitten: Adjust the default regex used to detect line numbers to handle - Hints kitten: Adjust the default regex used to detect line numbers to handle
line+column numbers (:iss:`2268`) line+column numbers (:iss:`2268`)

View File

@ -192,6 +192,12 @@ Similarly, you can detach the current tab, with::
# asks which OS Window to move the tab into # asks which OS Window to move the tab into
map ctrl+f4 detach_tab ask map ctrl+f4 detach_tab ask
Finally, you can define a shortcut to close all windows in a tab other than
the currently active window::
map f9 close_other_windows_in_tab
Other keyboard shortcuts Other keyboard shortcuts
---------------------------------- ----------------------------------

View File

@ -384,6 +384,13 @@ class Tab: # {{{
if self.windows: if self.windows:
self.remove_window(self.windows[self.active_window_idx]) self.remove_window(self.windows[self.active_window_idx])
def close_other_windows_in_tab(self) -> None:
if len(self.windows) > 1:
active_window = self.windows[self.active_window_idx]
for window in tuple(self.windows):
if window is not active_window:
self.remove_window(window)
def previous_active_window_idx(self, num: int) -> Optional[int]: def previous_active_window_idx(self, num: int) -> Optional[int]:
try: try:
old_window_id = self.active_window_history[-num] old_window_id = self.active_window_history[-num]