From 4575608a97fccca9083e5611965e4aff18d2949e Mon Sep 17 00:00:00 2001 From: Carlos Esparza Date: Fri, 16 Feb 2024 19:44:01 -0800 Subject: [PATCH] add `new-tab-neighbor` option to `detach_window` --- kitty/boss.py | 11 +++++++++-- kitty/options/utils.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index e0a7c5e98..c8386a2a7 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -2677,6 +2677,8 @@ class Boss: tm = self.os_window_map[target_os_window_id] if target_tab_id == 'new': target_tab = tm.new_tab(empty_tab=True) + elif target_tab_id == 'new_as_neighbor': + target_tab = tm.new_tab(empty_tab=True, as_neighbor=True) else: target_tab = tm.tab_at_location(target_tab_id) or tm.new_tab(empty_tab=True) else: @@ -2767,8 +2769,13 @@ class Boss: def detach_window(self, *args: str) -> None: if not args or args[0] == 'new': return self._move_window_to(target_os_window_id='new') - if args[0] in ('new-tab', 'tab-prev', 'tab-left', 'tab-right'): - where = 'new' if args[0] == 'new-tab' else args[0][4:] + if args[0] in ('new-tab', 'tab-prev', 'tab-left', 'tab-right', 'new-tab-neighbor'): + if args[0] == 'new-tab': + where = 'new' + elif args[0] == 'new-tab-neighbor': + where = 'new_as_neighbor' + else: + where = args[0][4:] return self._move_window_to(target_tab_id=where) ct = self.active_tab items: List[Tuple[Union[str, int], str]] = [(t.id, t.effective_title) for t in self.all_tabs if t is not ct] diff --git a/kitty/options/utils.py b/kitty/options/utils.py index c070d32d9..998f42805 100644 --- a/kitty/options/utils.py +++ b/kitty/options/utils.py @@ -144,7 +144,7 @@ def goto_tab_parse(func: str, rest: str) -> FuncArgsType: @func_with_args('detach_window') def detach_window_parse(func: str, rest: str) -> FuncArgsType: - if rest not in ('new', 'new-tab', 'ask', 'tab-prev', 'tab-left', 'tab-right'): + if rest not in ('new', 'new-tab', 'new-tab-neighbor', 'ask', 'tab-prev', 'tab-left', 'tab-right'): log_error(f'Ignoring invalid detach_window argument: {rest}') rest = 'new' return func, (rest,)