mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-13 12:09:35 +03:00
Have the :opt:confirm_os_window_close
option also apply when closing tabs with multiple windows
Fixes #2857
This commit is contained in:
parent
ff763b099e
commit
384ccb4fc7
@ -49,6 +49,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
|
||||
- Fix incorrect centering when a PUA or symbol glyph is followed by more than one space
|
||||
|
||||
- Have the :opt:`confirm_os_window_close` option also apply when closing tabs
|
||||
with multiple windows (:iss:`2857`)
|
||||
|
||||
|
||||
0.18.1 [2020-06-23]
|
||||
--------------------
|
||||
|
@ -444,8 +444,32 @@ class Boss:
|
||||
def close_tab(self, tab: Optional[Tab] = None) -> None:
|
||||
tab = tab or self.active_tab
|
||||
if tab:
|
||||
for window in tab:
|
||||
self.confirm_tab_close(tab)
|
||||
|
||||
def confirm_tab_close(self, tab: Tab) -> None:
|
||||
windows = tuple(tab)
|
||||
needs_confirmation = self.opts.confirm_os_window_close > 0 and len(windows) >= self.opts.confirm_os_window_close
|
||||
if not needs_confirmation:
|
||||
for window in windows:
|
||||
self.close_window(window)
|
||||
return
|
||||
self._run_kitten('ask', ['--type=yesno', '--message', _(
|
||||
'Are you sure you want to close this tab, it has {}'
|
||||
' windows running?').format(len(windows))],
|
||||
window=tab.active_window,
|
||||
custom_callback=partial(self.handle_close_tab_confirmation, tab.id)
|
||||
)
|
||||
|
||||
def handle_close_tab_confirmation(self, tab_id: int, data: Dict[str, Any], *a: Any) -> None:
|
||||
if data['response'] != 'y':
|
||||
return
|
||||
for tab in self.all_tabs:
|
||||
if tab.id == tab_id:
|
||||
break
|
||||
else:
|
||||
return
|
||||
for window in tab:
|
||||
self.close_window(window)
|
||||
|
||||
def toggle_fullscreen(self) -> None:
|
||||
toggle_fullscreen()
|
||||
|
@ -783,7 +783,7 @@ Note that this does not currently work on Wayland.
|
||||
'''))
|
||||
|
||||
o('confirm_os_window_close', 0, option_type=positive_int, long_text=_('''
|
||||
Ask for confirmation when closing an OS window that has at least this
|
||||
Ask for confirmation when closing an OS window or a tab that has at least this
|
||||
number of kitty windows in it. A value of zero disables confirmation.
|
||||
This confirmation also applies to requests to quit the entire application (all
|
||||
OS windows, via the quit action).
|
||||
|
Loading…
Reference in New Issue
Block a user