Merge :tab-detach with :tab-give
This commit is contained in:
parent
67437a0d5d
commit
29f66dcd95
@ -83,9 +83,8 @@ It is possible to run or bind multiple commands by separating them with `;;`.
|
|||||||
|<<stop,stop>>|Stop loading in the current/[count]th tab.
|
|<<stop,stop>>|Stop loading in the current/[count]th tab.
|
||||||
|<<tab-clone,tab-clone>>|Duplicate the current tab.
|
|<<tab-clone,tab-clone>>|Duplicate the current tab.
|
||||||
|<<tab-close,tab-close>>|Close the current/[count]th tab.
|
|<<tab-close,tab-close>>|Close the current/[count]th tab.
|
||||||
|<<tab-detach,tab-detach>>|Detach the current tab to its own window.
|
|
||||||
|<<tab-focus,tab-focus>>|Select the tab given as argument/[count].
|
|<<tab-focus,tab-focus>>|Select the tab given as argument/[count].
|
||||||
|<<tab-give,tab-give>>|Give the current tab to another window.
|
|<<tab-give,tab-give>>|Give the current tab to a new or existing window if win_id given.
|
||||||
|<<tab-move,tab-move>>|Move the current tab according to the argument and [count].
|
|<<tab-move,tab-move>>|Move the current tab according to the argument and [count].
|
||||||
|<<tab-next,tab-next>>|Switch to the next tab, or switch [count] tabs forward.
|
|<<tab-next,tab-next>>|Switch to the next tab, or switch [count] tabs forward.
|
||||||
|<<tab-only,tab-only>>|Close all tabs except for the current one.
|
|<<tab-only,tab-only>>|Close all tabs except for the current one.
|
||||||
@ -948,10 +947,6 @@ Close the current/[count]th tab.
|
|||||||
==== count
|
==== count
|
||||||
The tab index to close
|
The tab index to close
|
||||||
|
|
||||||
[[tab-detach]]
|
|
||||||
=== tab-detach
|
|
||||||
Detach the current tab to its own window.
|
|
||||||
|
|
||||||
[[tab-focus]]
|
[[tab-focus]]
|
||||||
=== tab-focus
|
=== tab-focus
|
||||||
Syntax: +:tab-focus ['index']+
|
Syntax: +:tab-focus ['index']+
|
||||||
@ -971,9 +966,11 @@ The tab index to focus, starting with 1.
|
|||||||
|
|
||||||
[[tab-give]]
|
[[tab-give]]
|
||||||
=== tab-give
|
=== tab-give
|
||||||
Syntax: +:tab-give 'win-id'+
|
Syntax: +:tab-give ['win-id']+
|
||||||
|
|
||||||
Give the current tab to another window.
|
Give the current tab to a new or existing window if win_id given.
|
||||||
|
|
||||||
|
If no win_id is given, the tab will get detached into a new window.
|
||||||
|
|
||||||
==== positional arguments
|
==== positional arguments
|
||||||
* +'win-id'+: The window ID of the window to give the current tab to.
|
* +'win-id'+: The window ID of the window to give the current tab to.
|
||||||
|
@ -513,16 +513,6 @@ class CommandDispatcher:
|
|||||||
new_tabbed_browser.set_tab_pinned(newtab, curtab.data.pinned)
|
new_tabbed_browser.set_tab_pinned(newtab, curtab.data.pinned)
|
||||||
return newtab
|
return newtab
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
|
||||||
def tab_detach(self):
|
|
||||||
"""Detach the current tab to its own window."""
|
|
||||||
if self._count() < 2:
|
|
||||||
raise cmdexc.CommandError("Cannot detach one tab.")
|
|
||||||
url = self._current_url()
|
|
||||||
self._open(url, window=True)
|
|
||||||
cur_widget = self._current_widget()
|
|
||||||
self._tabbed_browser.close_tab(cur_widget, add_undo=False)
|
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
@cmdutils.argument('index', completion=miscmodels.buffer)
|
@cmdutils.argument('index', completion=miscmodels.buffer)
|
||||||
def tab_take(self, index):
|
def tab_take(self, index):
|
||||||
@ -542,8 +532,10 @@ class CommandDispatcher:
|
|||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
@cmdutils.argument('win_id', completion=miscmodels.window)
|
@cmdutils.argument('win_id', completion=miscmodels.window)
|
||||||
def tab_give(self, win_id: int):
|
def tab_give(self, win_id: int = None):
|
||||||
"""Give the current tab to another window.
|
"""Give the current tab to a new or existing window if win_id given.
|
||||||
|
|
||||||
|
If no win_id is given, the tab will get detached into a new window.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
win_id: The window ID of the window to give the current tab to.
|
win_id: The window ID of the window to give the current tab to.
|
||||||
@ -551,8 +543,16 @@ class CommandDispatcher:
|
|||||||
if win_id == self._win_id:
|
if win_id == self._win_id:
|
||||||
raise cmdexc.CommandError("Can't give a tab to the same window")
|
raise cmdexc.CommandError("Can't give a tab to the same window")
|
||||||
|
|
||||||
|
if win_id is not None:
|
||||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
window=win_id)
|
window=win_id)
|
||||||
|
else:
|
||||||
|
if self._count() < 2:
|
||||||
|
raise cmdexc.CommandError("Cannot detach from a window with "
|
||||||
|
"only one tab")
|
||||||
|
|
||||||
|
tabbed_browser = self._new_tabbed_browser(
|
||||||
|
private=self._tabbed_browser.private)
|
||||||
tabbed_browser.tabopen(self._current_url())
|
tabbed_browser.tabopen(self._current_url())
|
||||||
self._tabbed_browser.close_tab(self._current_widget(), add_undo=False)
|
self._tabbed_browser.close_tab(self._current_widget(), add_undo=False)
|
||||||
|
|
||||||
|
@ -74,12 +74,12 @@ Feature: Invoking a new process
|
|||||||
|
|
||||||
# issue #1060
|
# issue #1060
|
||||||
|
|
||||||
Scenario: Using target_window = first-opened after tab-detach
|
Scenario: Using target_window = first-opened after tab-give
|
||||||
When I set new_instance_open_target to tab
|
When I set new_instance_open_target to tab
|
||||||
And I set new_instance_open_target_window to first-opened
|
And I set new_instance_open_target_window to first-opened
|
||||||
And I open data/title.html
|
And I open data/title.html
|
||||||
And I open data/search.html in a new tab
|
And I open data/search.html in a new tab
|
||||||
And I run :tab-detach
|
And I run :tab-give
|
||||||
And I wait until data/search.html is loaded
|
And I wait until data/search.html is loaded
|
||||||
And I open data/hello.txt as a URL
|
And I open data/hello.txt as a URL
|
||||||
Then the session should look like:
|
Then the session should look like:
|
||||||
|
@ -638,28 +638,6 @@ Feature: Tab management
|
|||||||
And I run :tab-clone
|
And I run :tab-clone
|
||||||
Then no crash should happen
|
Then no crash should happen
|
||||||
|
|
||||||
# :tab-detach
|
|
||||||
|
|
||||||
Scenario: Detaching a tab
|
|
||||||
When I open data/numbers/1.txt
|
|
||||||
And I open data/numbers/2.txt in a new tab
|
|
||||||
And I run :tab-detach
|
|
||||||
And I wait until data/numbers/2.txt is loaded
|
|
||||||
Then the session should look like:
|
|
||||||
windows:
|
|
||||||
- tabs:
|
|
||||||
- history:
|
|
||||||
- url: about:blank
|
|
||||||
- url: http://localhost:*/data/numbers/1.txt
|
|
||||||
- tabs:
|
|
||||||
- history:
|
|
||||||
- url: http://localhost:*/data/numbers/2.txt
|
|
||||||
|
|
||||||
Scenario: Detach tab from window with only one tab
|
|
||||||
When I open data/hello.txt
|
|
||||||
And I run :tab-detach
|
|
||||||
Then the error "Cannot detach one tab." should be shown
|
|
||||||
|
|
||||||
# :undo
|
# :undo
|
||||||
|
|
||||||
Scenario: Undo without any closed tabs
|
Scenario: Undo without any closed tabs
|
||||||
@ -1060,6 +1038,26 @@ Feature: Tab management
|
|||||||
And I run :tab-give 0
|
And I run :tab-give 0
|
||||||
Then the error "Can't give a tab to the same window" should be shown
|
Then the error "Can't give a tab to the same window" should be shown
|
||||||
|
|
||||||
|
Scenario: Give a tab to a new window
|
||||||
|
When I open data/numbers/1.txt
|
||||||
|
And I open data/numbers/2.txt in a new tab
|
||||||
|
And I run :tab-give
|
||||||
|
And I wait until data/numbers/2.txt is loaded
|
||||||
|
Then the session should look like:
|
||||||
|
windows:
|
||||||
|
- tabs:
|
||||||
|
- history:
|
||||||
|
- url: about:blank
|
||||||
|
- url: http://localhost:*/data/numbers/1.txt
|
||||||
|
- tabs:
|
||||||
|
- history:
|
||||||
|
- url: http://localhost:*/data/numbers/2.txt
|
||||||
|
|
||||||
|
Scenario: Give a tab from window with only one tab
|
||||||
|
When I open data/hello.txt
|
||||||
|
And I run :tab-give
|
||||||
|
Then the error "Cannot detach from a window with only one tab" should be shown
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
|
|
||||||
Scenario: Using :tab-next after closing last tab (#1448)
|
Scenario: Using :tab-next after closing last tab (#1448)
|
||||||
|
Loading…
Reference in New Issue
Block a user