From be05d9c3e9d62f4d192ffd5a9dddc162369e9b3a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 May 2020 15:12:20 +0530 Subject: [PATCH] Proper confirm_os_window_close check condition --- kitty/boss.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index 24b40b7d8..43fa8a564 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -732,7 +732,8 @@ def close_os_window(self) -> None: def confirm_os_window_close(self, os_window_id: int) -> None: tm = self.os_window_map.get(os_window_id) - if tm is None or self.opts.confirm_os_window_close > tm.number_of_windows: + needs_confirmation = tm is not None and self.opts.confirm_os_window_close > 0 and tm.number_of_windows >= self.opts.confirm_os_window_close + if not needs_confirmation: mark_os_window_for_close(os_window_id) return if tm is not None: @@ -768,11 +769,13 @@ def quit(self, *args: Any) -> None: num = 0 for q in self.os_window_map.values(): num += q.number_of_windows - if self.opts.confirm_os_window_close > num or tm is None: + needs_confirmation = tm is not None and self.opts.confirm_os_window_close > 0 and num >= self.opts.confirm_os_window_close + if not needs_confirmation: set_application_quit_request(IMPERATIVE_CLOSE_REQUESTED) return if current_application_quit_request() == CLOSE_BEING_CONFIRMED: return + assert tm is not None self._run_kitten('ask', ['--type=yesno', '--message', _( 'Are you sure you want to quit kitty, it has {} windows running?').format(num)], window=tm.active_window,