From 845298ae4117a898b84ca2d010ff3529d5922c04 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 18 Oct 2016 12:35:37 +0200 Subject: [PATCH] :tab-close option names --left -> --prev --right -> --next --- doc/help/commands.asciidoc | 6 +++--- qutebrowser/browser/commands.py | 22 +++++++++++----------- qutebrowser/config/configdata.py | 5 +++++ tests/end2end/features/tabs.feature | 10 +++++----- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 093b6f2c6..c54c4e04b 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -779,13 +779,13 @@ Duplicate the current tab. [[tab-close]] === tab-close -Syntax: +:tab-close [*--left*] [*--right*] [*--opposite*]+ +Syntax: +:tab-close [*--prev*] [*--next*] [*--opposite*]+ Close the current/[count]th tab. ==== optional arguments -* +*-l*+, +*--left*+: Force selecting the tab to the left of the current tab. -* +*-r*+, +*--right*+: Force selecting the tab to the right of the current tab. +* +*-p*+, +*--prev*+: Force selecting the tab before the current tab. +* +*-n*+, +*--next*+: Force selecting the tab after the current tab. * +*-o*+, +*--opposite*+: Force selecting the tab in the opposite direction of what's configured in 'tabs->select-on-remove'. diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index dc17c598f..87885d4cc 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -179,12 +179,12 @@ class CommandDispatcher: raise cmdexc.CommandError("Last focused tab vanished!") self._set_current_index(idx) - def _get_selection_override(self, left, right, opposite): + def _get_selection_override(self, prev, next_, opposite): """Helper function for tab_close to get the tab to select. Args: - left: Force selecting the tab to the left of the current tab. - right: Force selecting the tab to the right of the current tab. + prev: Force selecting the tab before the current tab. + next_: Force selecting the tab after the current tab. opposite: Force selecting the tab in the opposite direction of what's configured in 'tabs->select-on-remove'. @@ -192,10 +192,10 @@ class CommandDispatcher: QTabBar.SelectLeftTab, QTabBar.SelectRightTab, or None if no change should be made. """ - cmdutils.check_exclusive((left, right, opposite), 'lro') - if left: + cmdutils.check_exclusive((prev, next_, opposite), 'pno') + if prev: return QTabBar.SelectLeftTab - elif right: + elif next_: return QTabBar.SelectRightTab elif opposite: conf_selection = config.get('tabs', 'select-on-remove') @@ -206,7 +206,7 @@ class CommandDispatcher: elif conf_selection == QTabBar.SelectPreviousTab: raise cmdexc.CommandError( "-o is not supported with 'tabs->select-on-remove' set to " - "'previous'!") + "'last-used'!") else: # pragma: no cover raise ValueError("Invalid select-on-remove value " "{!r}!".format(conf_selection)) @@ -214,12 +214,12 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) - def tab_close(self, left=False, right=False, opposite=False, count=None): + def tab_close(self, prev=False, next_=False, opposite=False, count=None): """Close the current/[count]th tab. Args: - left: Force selecting the tab to the left of the current tab. - right: Force selecting the tab to the right of the current tab. + prev: Force selecting the tab before the current tab. + next_: Force selecting the tab after the current tab. opposite: Force selecting the tab in the opposite direction of what's configured in 'tabs->select-on-remove'. count: The tab index to close, or None @@ -228,7 +228,7 @@ class CommandDispatcher: if tab is None: return tabbar = self._tabbed_browser.tabBar() - selection_override = self._get_selection_override(left, right, + selection_override = self._get_selection_override(prev, next_, opposite) if selection_override is None: self._tabbed_browser.close_tab(tab) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index e76bc6468..a8c5fed88 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1781,4 +1781,9 @@ CHANGED_KEY_COMMANDS = [ (re.compile(r'^prompt-yes$'), r'prompt-accept yes'), (re.compile(r'^prompt-no$'), r'prompt-accept no'), + + (re.compile(r'^tab-close -l$'), r'tab-close --prev'), + (re.compile(r'^tab-close --left$'), r'tab-close --prev'), + (re.compile(r'^tab-close -r$'), r'tab-close --next'), + (re.compile(r'^tab-close --right$'), r'tab-close --next'), ] diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 717f39a73..de8742579 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -70,24 +70,24 @@ Feature: Tab management - data/numbers/3.txt - data/numbers/4.txt (active) - Scenario: :tab-close with select-on-remove = prev and --right + Scenario: :tab-close with select-on-remove = prev and --next When I set tabs -> select-on-remove to prev And I open data/numbers/1.txt And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 - And I run :tab-close --right + And I run :tab-close --next Then the following tabs should be open: - data/numbers/1.txt - data/numbers/3.txt (active) - Scenario: :tab-close with select-on-remove = next and --left + Scenario: :tab-close with select-on-remove = next and --prev When I set tabs -> select-on-remove to next And I open data/numbers/1.txt And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 - And I run :tab-close --left + And I run :tab-close --prev Then the following tabs should be open: - data/numbers/1.txt (active) - data/numbers/3.txt @@ -126,7 +126,7 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I open data/numbers/4.txt in a new tab And I run :tab-focus 2 - And I run :tab-close --left + And I run :tab-close --prev And I run :tab-focus 2 And I run :tab-close Then the following tabs should be open: