summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorharish3124 <harishhari3112004@gmail.com>2021-11-11 11:44:24 +0530
committerharish3124 <harishhari3112004@gmail.com>2021-11-11 11:44:24 +0530
commitaba0ee5c2e1849fda00888b5c32986051d5fe440 (patch)
tree5adcd846f94f0844e32d2f865628ed9c53415117
parent1f641c8c450d21441d36194bd606b64d362a6f75 (diff)
downloadqutebrowser-aba0ee5c2e1849fda00888b5c32986051d5fe440.tar.gz
qutebrowser-aba0ee5c2e1849fda00888b5c32986051d5fe440.zip
Added Start/End arguments to :tab-move
-rw-r--r--qutebrowser/browser/commands.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index f3438aaa8..eccb64b9e 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -1004,11 +1004,10 @@ class CommandDispatcher:
raise cmdutils.CommandError("There's no tab with index {}!".format(
index))
- @cmdutils.register(instance='command-dispatcher', scope='window')
- @cmdutils.argument('index', choices=['+', '-'])
- @cmdutils.argument('count', value=cmdutils.Value.count)
- def tab_move(self, index: Union[str, int] = None,
- count: int = None) -> None:
+ @cmdutils.register(instance="command-dispatcher", scope="window")
+ @cmdutils.argument("index", choices=["+", "-", "start", "end"])
+ @cmdutils.argument("count", value=cmdutils.Value.count)
+ def tab_move(self, index: Union[str, int] = None, count: int = None) -> None:
"""Move the current tab according to the argument and [count].
If neither is given, move it to the first position.
@@ -1021,20 +1020,24 @@ class CommandDispatcher:
If moving absolutely: New position (default: 0). This
overrides the index argument, if given.
"""
- if index in ['+', '-']:
+ if index in ["+", "-"]:
# relative moving
new_idx = self._current_index()
delta = 1 if count is None else count
- if index == '-':
+ if index == "-":
new_idx -= delta
- elif index == '+': # pragma: no branch
+ elif index == "+": # pragma: no branch
new_idx += delta
if config.val.tabs.wrap:
new_idx %= self._count()
else:
# absolute moving
- if count is not None:
+ if index == "start":
+ new_idx = 0
+ elif index == "end":
+ new_idx = self._count() - 1
+ elif count is not None:
new_idx = count - 1
elif index is not None:
assert isinstance(index, int)