diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index e202e9ece..157c8a33c 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -74,6 +74,10 @@ Changed download. - Much improved user stylesheet handling which reduces flickering and updates immediately after setting a stylesheet. +- `:completion-item-focus` now has a `--history` flag which causes it to go + through the command history when no text was entered. The default bindings for + cursor keys in the completion changed to use that, so that they can be used + again to navigate through completion items when a text was entered. Fixed ~~~~~ diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 29679913e..18e0aee92 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -1428,13 +1428,16 @@ Delete the current completion item. [[completion-item-focus]] === completion-item-focus -Syntax: +:completion-item-focus 'which'+ +Syntax: +:completion-item-focus [*--history*] 'which'+ Shift the focus of the completion menu to another item. ==== positional arguments * +'which'+: 'next', 'prev', 'next-category', or 'prev-category'. +==== optional arguments +* +*-H*+, +*--history*+: Navigate through command history if no text was typed. + [[completion-item-yank]] === completion-item-yank Syntax: +:completion-item-yank [*--sel*]+ diff --git a/doc/help/configuring.asciidoc b/doc/help/configuring.asciidoc index 347f7b49b..766e6bc7f 100644 --- a/doc/help/configuring.asciidoc +++ b/doc/help/configuring.asciidoc @@ -17,15 +17,24 @@ did in your old configuration, compared to the old defaults. Other changes in default settings: -- `` and `` in the completion now navigate through command history - instead of selecting completion items. Use ``/`` to cycle - through the completion instead. +- In v1.1.x and newer, `` and `` navigate through command history + if no text was entered yet. + With v1.0.x, they always navigate through command history instead of selecting + completion items. Use ``/`` to cycle through the completion + instead. You can get back the old behavior by doing: + ---- :bind -m command completion-item-focus prev :bind -m command completion-item-focus next ---- ++ +or always navigate through command history with ++ +---- +:bind -m command command-history-prev +:bind -m command command-history-next +---- - The default for `completion.web_history_max_items` is now set to `-1`, showing an unlimited number of items in the completion for `:open` as the new diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 64881f619..60afca0f9 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -430,13 +430,13 @@ Default: * +pass:[<Ctrl-U>]+: +pass:[rl-unix-line-discard]+ * +pass:[<Ctrl-W>]+: +pass:[rl-unix-word-rubout]+ * +pass:[<Ctrl-Y>]+: +pass:[rl-yank]+ -* +pass:[<Down>]+: +pass:[command-history-next]+ +* +pass:[<Down>]+: +pass:[completion-item-focus --history next]+ * +pass:[<Escape>]+: +pass:[leave-mode]+ * +pass:[<Return>]+: +pass:[command-accept]+ * +pass:[<Shift-Delete>]+: +pass:[completion-item-del]+ * +pass:[<Shift-Tab>]+: +pass:[completion-item-focus prev]+ * +pass:[<Tab>]+: +pass:[completion-item-focus next]+ -* +pass:[<Up>]+: +pass:[command-history-prev]+ +* +pass:[<Up>]+: +pass:[completion-item-focus --history priv]+ - +pass:[hint]+: * +pass:[<Ctrl-B>]+: +pass:[hint all tab-bg]+ diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 67864ce5f..563da166e 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -226,14 +226,31 @@ class CompletionView(QTreeView): modes=[usertypes.KeyMode.command], scope='window') @cmdutils.argument('which', choices=['next', 'prev', 'next-category', 'prev-category']) - def completion_item_focus(self, which): + @cmdutils.argument('history', flag='H') + def completion_item_focus(self, which, history=False): """Shift the focus of the completion menu to another item. Args: which: 'next', 'prev', 'next-category', or 'prev-category'. + history: Navigate through command history if no text was typed. """ if not self._active: return + + if history: + status = objreg.get('status-command', scope='window', + window=self._win_id) + if status.text() == ':' or status.history.is_browsing(): + if which == 'next': + status.command_history_next() + return + elif which == 'prev': + status.command_history_prev() + return + else: + raise cmdexc.CommandError("Can't combine --history with " + "{}!".format(which)) + selmodel = self.selectionModel() if which == 'next': diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index ba8c36857..c2d5e21bb 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -2269,8 +2269,8 @@ bindings.default: command: : command-history-prev : command-history-next - : command-history-prev - : command-history-next + : completion-item-focus --history prev + : completion-item-focus --history next : completion-item-focus prev : completion-item-focus next : completion-item-focus next-category diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 701ff3feb..009792838 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -469,6 +469,15 @@ Feature: Various utility commands. And I run :command-accept Then the message "blah" should be shown + Scenario: Calling previous command with :completion-item-focus + When I run :set-cmd-text :message-info blah + And I run :command-accept + And I wait for "blah" in the log + And I run :set-cmd-text : + And I run :completion-item-focus prev --history + And I run :command-accept + Then the message "blah" should be shown + Scenario: Browsing through commands When I run :set-cmd-text :message-info blarg And I run :command-accept