Add :window-only command

I mainly added this so I can speed up all of the tests that rely on
closing other windows.
This commit is contained in:
Niklas Haas 2016-08-11 23:37:14 +02:00
parent b51dffc517
commit d5080bdb1a
No known key found for this signature in database
GPG Key ID: 9A09076581B27402
3 changed files with 22 additions and 0 deletions

View File

@ -32,6 +32,7 @@ Added
in rapid mode.
- New `{clipboard}` and `{primary}` replacements for the commandline which
replace the `:paste` command.
- New `:window-only` command to close all other windows.
Changed
~~~~~~~

View File

@ -769,6 +769,13 @@ class CommandDispatcher:
raise cmdexc.CommandError("Can't zoom {}%!".format(level))
message.info(self._win_id, "Zoom level: {}%".format(level))
@cmdutils.register(instance='command-dispatcher', scope='window')
def window_only(self):
"""Close all windows except for the current one."""
for win_id, window in objreg.window_registry.items():
if win_id != self._win_id:
window.close()
@cmdutils.register(instance='command-dispatcher', scope='window')
def tab_only(self, left=False, right=False):
"""Close all tabs except for the current one.

View File

@ -525,6 +525,20 @@ Feature: Various utility commands.
- data/hints/link_blank.html
- data/hello.txt (active)
@no_xvfb
Scenario: :window-only
Given I run :tab-only
And I open data/hello.txt
When I open data/hello2.txt in a new tab
And I open data/hello3.txt in a new window
And I run :window-only
Then the session should look like:
windows:
- tabs:
- active: true
history:
- url: http://localhost:*/data/hello3.txt
## Variables
Scenario: {url} as part of an argument