add new-tab-left and new-tab-right

This commit is contained in:
Carlos Esparza 2024-02-17 00:06:15 -08:00 committed by Kovid Goyal
parent 4575608a97
commit 299c39a214
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 8 deletions

View file

@ -2675,10 +2675,9 @@ def _move_window_to(
tm = q
else:
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)
if target_tab_id.startswith('new'):
# valid values for target_tab_id are 'new', 'new_after' and 'new_before'
target_tab = tm.new_tab(empty_tab=True, location=(target_tab_id[4:] or 'last'))
else:
target_tab = tm.tab_at_location(target_tab_id) or tm.new_tab(empty_tab=True)
else:
@ -2769,11 +2768,13 @@ def format_tab_title(tab: Tab) -> str:
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', 'new-tab-neighbor'):
if args[0] in ('new-tab', 'tab-prev', 'tab-left', 'tab-right', 'new-tab-left', 'new-tab-right'):
if args[0] == 'new-tab':
where = 'new'
elif args[0] == 'new-tab-neighbor':
where = 'new_as_neighbor'
elif args[0] == 'new-tab-right':
where = 'new_after'
elif args[0] == 'new-tab-left':
where = 'new_before'
else:
where = args[0][4:]
return self._move_window_to(target_tab_id=where)

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', 'new-tab-neighbor', 'ask', 'tab-prev', 'tab-left', 'tab-right'):
if rest not in ('new', 'new-tab', 'new-tab-left', 'new-tab-right', 'ask', 'tab-prev', 'tab-left', 'tab-right'):
log_error(f'Ignoring invalid detach_window argument: {rest}')
rest = 'new'
return func, (rest,)