Merge branch 'pr/3024'
This commit is contained in:
commit
ad867a3b90
@ -185,16 +185,19 @@ Load a bookmark.
|
|||||||
|
|
||||||
[[buffer]]
|
[[buffer]]
|
||||||
=== buffer
|
=== buffer
|
||||||
Syntax: +:buffer 'index'+
|
Syntax: +:buffer ['index']+
|
||||||
|
|
||||||
Select tab by index or url/title best match.
|
Select tab by index or url/title best match.
|
||||||
|
|
||||||
Focuses window if necessary.
|
Focuses window if necessary when index is given. If both index and count are given, use count.
|
||||||
|
|
||||||
==== positional arguments
|
==== positional arguments
|
||||||
* +'index'+: The [win_id/]index of the tab to focus. Or a substring in which case the closest match will be focused.
|
* +'index'+: The [win_id/]index of the tab to focus. Or a substring in which case the closest match will be focused.
|
||||||
|
|
||||||
|
|
||||||
|
==== count
|
||||||
|
The tab index to focus, starting with 1.
|
||||||
|
|
||||||
[[close]]
|
[[close]]
|
||||||
=== close
|
=== close
|
||||||
Close the current window.
|
Close the current window.
|
||||||
|
@ -1011,29 +1011,38 @@ class CommandDispatcher:
|
|||||||
|
|
||||||
@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 buffer(self, index):
|
@cmdutils.argument('count', count=True)
|
||||||
|
def buffer(self, index=None, count=None):
|
||||||
"""Select tab by index or url/title best match.
|
"""Select tab by index or url/title best match.
|
||||||
|
|
||||||
Focuses window if necessary.
|
Focuses window if necessary when index is given. If both index and
|
||||||
|
count are given, use count.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
index: The [win_id/]index of the tab to focus. Or a substring
|
index: The [win_id/]index of the tab to focus. Or a substring
|
||||||
in which case the closest match will be focused.
|
in which case the closest match will be focused.
|
||||||
|
count: The tab index to focus, starting with 1.
|
||||||
"""
|
"""
|
||||||
index_parts = index.split('/', 1)
|
if count is not None:
|
||||||
|
index_parts = [count]
|
||||||
|
elif index is None:
|
||||||
|
raise cmdexc.CommandError("buffer: Either a count or the argument "
|
||||||
|
"index must be specified.")
|
||||||
|
else:
|
||||||
|
index_parts = index.split('/', 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for part in index_parts:
|
for part in index_parts:
|
||||||
int(part)
|
int(part)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
model = miscmodels.buffer()
|
model = miscmodels.buffer()
|
||||||
model.set_pattern(index)
|
model.set_pattern(index)
|
||||||
if model.count() > 0:
|
if model.count() > 0:
|
||||||
index = model.data(model.first_item())
|
index = model.data(model.first_item())
|
||||||
index_parts = index.split('/', 1)
|
index_parts = index.split('/', 1)
|
||||||
else:
|
else:
|
||||||
raise cmdexc.CommandError(
|
raise cmdexc.CommandError(
|
||||||
"No matching tab for: {}".format(index))
|
"No matching tab for: {}".format(index))
|
||||||
|
|
||||||
if len(index_parts) == 2:
|
if len(index_parts) == 2:
|
||||||
win_id = int(index_parts[0])
|
win_id = int(index_parts[0])
|
||||||
|
@ -897,9 +897,9 @@ Feature: Tab management
|
|||||||
|
|
||||||
# :buffer
|
# :buffer
|
||||||
|
|
||||||
Scenario: :buffer without args
|
Scenario: :buffer without args or count
|
||||||
When I run :buffer
|
When I run :buffer
|
||||||
Then the error "buffer: The following arguments are required: index" should be shown
|
Then the error "buffer: Either a count or the argument index must be specified." should be shown
|
||||||
|
|
||||||
Scenario: :buffer with a matching title
|
Scenario: :buffer with a matching title
|
||||||
When I open data/title.html
|
When I open data/title.html
|
||||||
|
Loading…
Reference in New Issue
Block a user