Merge branch 'add_option_to_not_switch_to_previous_when_closing_current_tab' of https://github.com/ddddavidmartin/kitty
This commit is contained in:
commit
c9644039b1
@ -28,6 +28,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
|
||||
- Allow setting OS window size in session files
|
||||
|
||||
- Add an option :opt:`tab_switch_strategy` to control which
|
||||
tab becomes active when the current tab is closed (:pull:`1524`)
|
||||
|
||||
- Allow specifying a value of ``none`` for the :opt:`selection_foreground`
|
||||
which will cause kitty to not change text color in selections (:iss:`1358`)
|
||||
|
||||
|
||||
@ -631,6 +631,13 @@ o('tab_bar_min_tabs', 2, option_type=lambda x: max(1, positive_int(x)), long_tex
|
||||
The minimum number of tabs that must exist before the tab bar is shown
|
||||
'''))
|
||||
|
||||
o('tab_switch_strategy', 'previous', option_type=choices('previous', 'left', 'last'), long_text=_('''
|
||||
The algorithm to use when switching to a tab when the current tab is closed.
|
||||
The default of :code:`previous` will switch to the last used tab. A value of
|
||||
:code:`left` will switch to the tab to the left of the closed tab. A value
|
||||
of :code:`last` will switch to the right-most tab.
|
||||
'''))
|
||||
|
||||
|
||||
def tab_fade(x):
|
||||
return tuple(map(unit_float, x.split()))
|
||||
|
||||
@ -552,16 +552,25 @@ class TabManager: # {{{
|
||||
def remove(self, tab):
|
||||
self._remove_tab(tab)
|
||||
next_active_tab = -1
|
||||
while self.active_tab_history and next_active_tab < 0:
|
||||
tab_id = self.active_tab_history.pop()
|
||||
if tab_id == tab.id:
|
||||
continue
|
||||
for idx, qtab in enumerate(self.tabs):
|
||||
if qtab.id == tab_id:
|
||||
next_active_tab = idx
|
||||
break
|
||||
while True:
|
||||
try:
|
||||
self.active_tab_history.remove(tab.id)
|
||||
except ValueError:
|
||||
break
|
||||
|
||||
if self.opts.tab_switch_strategy == 'previous':
|
||||
while self.active_tab_history and next_active_tab < 0:
|
||||
tab_id = self.active_tab_history.pop()
|
||||
for idx, qtab in enumerate(self.tabs):
|
||||
if qtab.id == tab_id:
|
||||
next_active_tab = idx
|
||||
break
|
||||
elif self.opts.tab_switch_strategy == 'left':
|
||||
next_active_tab = max(0, self.active_tab_idx - 1)
|
||||
|
||||
if next_active_tab < 0:
|
||||
next_active_tab = max(0, min(self.active_tab_idx, len(self.tabs) - 1))
|
||||
|
||||
self._set_active_tab(next_active_tab)
|
||||
self.mark_tab_bar_dirty()
|
||||
tab.destroy()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user