Make cursor keys go through completion if a text was entered
This hopefully helps with people who try to use arrow keys for the completion, while still making the command history somewhat discoverable.
This commit is contained in:
parent
c14135a6ce
commit
62f37df573
@ -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
|
||||
~~~~~
|
||||
|
@ -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*]+
|
||||
|
@ -17,15 +17,24 @@ did in your old configuration, compared to the old defaults.
|
||||
|
||||
Other changes in default settings:
|
||||
|
||||
- `<Up>` and `<Down>` in the completion now navigate through command history
|
||||
instead of selecting completion items. Use `<Tab>`/`<Shift-Tab>` to cycle
|
||||
through the completion instead.
|
||||
- In v1.1.x and newer, `<Up>` and `<Down>` 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 `<Tab>`/`<Shift-Tab>` to cycle through the completion
|
||||
instead.
|
||||
You can get back the old behavior by doing:
|
||||
+
|
||||
----
|
||||
:bind -m command <Up> completion-item-focus prev
|
||||
:bind -m command <Down> completion-item-focus next
|
||||
----
|
||||
+
|
||||
or always navigate through command history with
|
||||
+
|
||||
----
|
||||
:bind -m command <Up> command-history-prev
|
||||
:bind -m command <Down> 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
|
||||
|
@ -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]+
|
||||
|
@ -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':
|
||||
|
@ -2269,8 +2269,8 @@ bindings.default:
|
||||
command:
|
||||
<Ctrl-P>: command-history-prev
|
||||
<Ctrl-N>: command-history-next
|
||||
<Up>: command-history-prev
|
||||
<Down>: command-history-next
|
||||
<Up>: completion-item-focus --history prev
|
||||
<Down>: completion-item-focus --history next
|
||||
<Shift-Tab>: completion-item-focus prev
|
||||
<Tab>: completion-item-focus next
|
||||
<Ctrl-Tab>: completion-item-focus next-category
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user