When mapping the new_tab action allow specifying that the tab should open next to the current tab instead of at the end of the tabs list

Fixes #979
This commit is contained in:
Kovid Goyal
2018-09-19 19:43:41 +05:30
parent edfb4ef3f1
commit 5fb02c0439
4 changed files with 27 additions and 6 deletions

View File

@@ -464,10 +464,16 @@ class TabManager: # {{{
self._set_active_tab(nidx)
self.mark_tab_bar_dirty()
def new_tab(self, special_window=None, cwd_from=None):
def new_tab(self, special_window=None, cwd_from=None, as_neighbor=False):
nidx = self.active_tab_idx + 1
idx = len(self.tabs)
self._add_tab(Tab(self, special_window=special_window, cwd_from=cwd_from))
self._set_active_tab(idx)
if len(self.tabs) > 2 and as_neighbor and idx != nidx:
self.tabs[idx], self.tabs[nidx] = self.tabs[nidx], self.tabs[idx]
swap_tabs(self.os_window_id, idx, nidx)
self._set_active_tab(nidx)
idx = nidx
self.mark_tab_bar_dirty()
return self.tabs[idx]