Merge remote-tracking branch 'origin/pr/3467'
This commit is contained in:
commit
923785c781
@ -953,22 +953,25 @@ class CommandDispatcher:
|
||||
(prev and i < cur_idx) or
|
||||
(next_ and i > cur_idx))
|
||||
|
||||
# Check to see if we are closing any pinned tabs
|
||||
if not force:
|
||||
for i, tab in enumerate(self._tabbed_browser.widgets()):
|
||||
if _to_close(i) and tab.data.pinned:
|
||||
self._tabbed_browser.tab_close_prompt_if_pinned(
|
||||
tab,
|
||||
force,
|
||||
lambda: self.tab_only(
|
||||
prev=prev, next_=next_, force=True))
|
||||
return
|
||||
|
||||
# close as many tabs as we can
|
||||
first_tab = True
|
||||
pinned_tabs_cleanup = False
|
||||
for i, tab in enumerate(self._tabbed_browser.widgets()):
|
||||
if _to_close(i):
|
||||
self._tabbed_browser.close_tab(tab, new_undo=first_tab)
|
||||
first_tab = False
|
||||
if force or not tab.data.pinned:
|
||||
self._tabbed_browser.close_tab(tab, new_undo=first_tab)
|
||||
first_tab = False
|
||||
else:
|
||||
pinned_tabs_cleanup = tab
|
||||
|
||||
# Check to see if we would like to close any pinned tabs
|
||||
if pinned_tabs_cleanup:
|
||||
self._tabbed_browser.tab_close_prompt_if_pinned(
|
||||
pinned_tabs_cleanup,
|
||||
force,
|
||||
lambda: self.tab_only(
|
||||
prev=prev, next_=next_, force=True),
|
||||
text="Are you sure you want to close pinned tabs?")
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
def undo(self):
|
||||
|
@ -256,7 +256,9 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
for tab in self.widgets():
|
||||
self._remove_tab(tab)
|
||||
|
||||
def tab_close_prompt_if_pinned(self, tab, force, yes_action):
|
||||
def tab_close_prompt_if_pinned(
|
||||
self, tab, force, yes_action,
|
||||
text="Are you sure you want to close a pinned tab?"):
|
||||
"""Helper method for tab_close.
|
||||
|
||||
If tab is pinned, prompt. If not, run yes_action.
|
||||
@ -265,7 +267,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
if tab.data.pinned and not force:
|
||||
message.confirm_async(
|
||||
title='Pinned Tab',
|
||||
text="Are you sure you want to close a pinned tab?",
|
||||
text=text,
|
||||
yes_action=yes_action, default=False, abort_on=[tab.destroyed])
|
||||
else:
|
||||
yes_action()
|
||||
|
@ -1183,7 +1183,7 @@ Feature: Tab management
|
||||
And I run :tab-pin
|
||||
And I run :tab-next
|
||||
And I run :tab-only
|
||||
And I wait for "*want to close a pinned tab*" in the log
|
||||
And I wait for "*want to close pinned tabs*" in the log
|
||||
And I run :prompt-accept yes
|
||||
Then the following tabs should be open:
|
||||
- data/numbers/1.txt (active) (pinned)
|
||||
@ -1195,7 +1195,7 @@ Feature: Tab management
|
||||
And I run :tab-pin
|
||||
And I run :tab-next
|
||||
And I run :tab-only
|
||||
And I wait for "*want to close a pinned tab*" in the log
|
||||
And I wait for "*want to close pinned tabs*" in the log
|
||||
And I run :prompt-accept no
|
||||
Then the following tabs should be open:
|
||||
- data/numbers/1.txt (active) (pinned)
|
||||
|
Loading…
Reference in New Issue
Block a user