add new-tab-neighbor option to detach_window

This commit is contained in:
Carlos Esparza
2024-02-16 19:44:01 -08:00
committed by Kovid Goyal
parent 1a9a7a59ac
commit 4575608a97
2 changed files with 10 additions and 3 deletions

View File

@@ -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]

View File

@@ -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,)