This commit is contained in:
Max 2026-01-07 16:40:42 -08:00 committed by GitHub
commit a58fd472d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View File

@ -1519,7 +1519,7 @@ How many tabs to switch back.
[[tab-select]]
=== tab-select
Syntax: +:tab-select ['index']+
Syntax: +:tab-select [*--open*] ['index']+
Select tab by index or url/title best match.
@ -1528,6 +1528,8 @@ Focuses window if necessary when index is given. If both index and count are giv
==== positional arguments
* +'index'+: The [win_id/]index of the tab to focus. Or a substring in which case the closest match will be focused.
==== optional arguments
* +*-o*+, +*--open*+: If index is a substring and it didn't match any tab, open it in a new tab.
==== count
The tab index to focus, starting with 1.

View File

@ -945,7 +945,7 @@ class CommandDispatcher:
maxsplit=0)
@cmdutils.argument('index', completion=miscmodels.tabs)
@cmdutils.argument('count', value=cmdutils.Value.count)
def tab_select(self, index=None, count=None):
def tab_select(self, index=None, new=False, count=None):
"""Select tab by index or url/title best match.
Focuses window if necessary when index is given. If both index and
@ -957,6 +957,7 @@ class CommandDispatcher:
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.
open: If index is a substring and it didn't match any tab, open it in a new tab.
"""
if count is None and index is None:
self.openurl('qute://tabs/', tab=True)
@ -965,7 +966,14 @@ class CommandDispatcher:
if count is not None:
index = str(count)
tabbed_browser, tab = self._resolve_tab_index(index)
tabbed_browser, tab = None, None
try:
tabbed_browser, tab = self._resolve_tab_index(index)
except cmdutils.CommandError:
if new:
self.openurl(index, tab=True)
return
raise
window = tabbed_browser.widget.window()
mainwindow.raise_window(window)