Clear unpinned tabs before prompting user with :tab-only
This commit is contained in:
parent
c3bcb1d9ba
commit
3d508be9ff
@ -953,22 +953,25 @@ class CommandDispatcher:
|
|||||||
(prev and i < cur_idx) or
|
(prev and i < cur_idx) or
|
||||||
(next_ and i > cur_idx))
|
(next_ and i > cur_idx))
|
||||||
|
|
||||||
# Check to see if we are closing any pinned tabs
|
# close as many tabs as we can
|
||||||
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
|
|
||||||
|
|
||||||
first_tab = True
|
first_tab = True
|
||||||
|
pinned_tabs_cleanup = False
|
||||||
for i, tab in enumerate(self._tabbed_browser.widgets()):
|
for i, tab in enumerate(self._tabbed_browser.widgets()):
|
||||||
if _to_close(i):
|
if _to_close(i):
|
||||||
self._tabbed_browser.close_tab(tab, new_undo=first_tab)
|
if force or not tab.data.pinned:
|
||||||
first_tab = False
|
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')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
def undo(self):
|
def undo(self):
|
||||||
|
@ -256,7 +256,9 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
for tab in self.widgets():
|
for tab in self.widgets():
|
||||||
self._remove_tab(tab)
|
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.
|
"""Helper method for tab_close.
|
||||||
|
|
||||||
If tab is pinned, prompt. If not, run yes_action.
|
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:
|
if tab.data.pinned and not force:
|
||||||
message.confirm_async(
|
message.confirm_async(
|
||||||
title='Pinned Tab',
|
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])
|
yes_action=yes_action, default=False, abort_on=[tab.destroyed])
|
||||||
else:
|
else:
|
||||||
yes_action()
|
yes_action()
|
||||||
|
@ -1183,7 +1183,7 @@ Feature: Tab management
|
|||||||
And I run :tab-pin
|
And I run :tab-pin
|
||||||
And I run :tab-next
|
And I run :tab-next
|
||||||
And I run :tab-only
|
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
|
And I run :prompt-accept yes
|
||||||
Then the following tabs should be open:
|
Then the following tabs should be open:
|
||||||
- data/numbers/1.txt (active) (pinned)
|
- data/numbers/1.txt (active) (pinned)
|
||||||
@ -1195,7 +1195,7 @@ Feature: Tab management
|
|||||||
And I run :tab-pin
|
And I run :tab-pin
|
||||||
And I run :tab-next
|
And I run :tab-next
|
||||||
And I run :tab-only
|
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
|
And I run :prompt-accept no
|
||||||
Then the following tabs should be open:
|
Then the following tabs should be open:
|
||||||
- data/numbers/1.txt (active) (pinned)
|
- data/numbers/1.txt (active) (pinned)
|
||||||
|
Loading…
Reference in New Issue
Block a user