Show command completions for :bind.
All commands will be offered as completions for the <command> argument of :bind. Due to the way completers parse the command line, the following bind --mode caret j will throw off completions as 'caret' is treated as a positional arg in terms of the argument count for completions. In the above example, completion will be triggered for 'j' and no completions will be given for the actual command. bind --mode=caret j will complete correctly, though completions are not filtered by the given mode. I attempted an approach to filter the commands based on the mode but it ended up being messy and flaky.
This commit is contained in:
parent
2536766cac
commit
b8a593cac5
@ -29,7 +29,8 @@ import functools
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
|
||||
from qutebrowser.completion.models import miscmodels, urlmodel, configmodel
|
||||
from qutebrowser.completion.models import (miscmodels, urlmodel, configmodel,
|
||||
base)
|
||||
from qutebrowser.utils import objreg, usertypes, log, debug
|
||||
from qutebrowser.config import configdata
|
||||
|
||||
@ -119,6 +120,13 @@ def init_session_completion():
|
||||
_instances[usertypes.Completion.sessions] = model
|
||||
|
||||
|
||||
def _init_empty_completion():
|
||||
"""Initialize empty completion model."""
|
||||
log.completion.debug("Initializing empty completion.")
|
||||
if usertypes.Completion.empty not in _instances:
|
||||
_instances[usertypes.Completion.empty] = base.BaseCompletionModel()
|
||||
|
||||
|
||||
INITIALIZERS = {
|
||||
usertypes.Completion.command: _init_command_completion,
|
||||
usertypes.Completion.helptopic: _init_helptopic_completion,
|
||||
@ -130,6 +138,7 @@ INITIALIZERS = {
|
||||
usertypes.Completion.quickmark_by_name: init_quickmark_completions,
|
||||
usertypes.Completion.bookmark_by_url: init_bookmark_completions,
|
||||
usertypes.Completion.sessions: init_session_completion,
|
||||
usertypes.Completion.empty: _init_empty_completion,
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ from PyQt5.QtCore import pyqtSignal, QObject
|
||||
|
||||
from qutebrowser.config import configdata, textwrapper
|
||||
from qutebrowser.commands import cmdutils, cmdexc
|
||||
from qutebrowser.utils import log, utils, qtutils, message
|
||||
from qutebrowser.utils import log, utils, qtutils, message, usertypes
|
||||
|
||||
|
||||
class KeyConfigError(Exception):
|
||||
@ -151,7 +151,9 @@ class KeyConfigParser(QObject):
|
||||
f.write(data)
|
||||
|
||||
@cmdutils.register(instance='key-config', maxsplit=1, no_cmd_split=True,
|
||||
win_id='win_id')
|
||||
win_id='win_id',
|
||||
completion=[usertypes.Completion.empty,
|
||||
usertypes.Completion.command])
|
||||
def bind(self, key, win_id, command=None, *, mode=None, force=False):
|
||||
"""Bind a key to a command.
|
||||
|
||||
|
@ -238,7 +238,8 @@ KeyMode = enum('KeyMode', ['normal', 'hint', 'command', 'yesno', 'prompt',
|
||||
# Available command completions
|
||||
Completion = enum('Completion', ['command', 'section', 'option', 'value',
|
||||
'helptopic', 'quickmark_by_name',
|
||||
'bookmark_by_url', 'url', 'tab', 'sessions'])
|
||||
'bookmark_by_url', 'url', 'tab', 'sessions',
|
||||
'empty'])
|
||||
|
||||
|
||||
# Exit statuses for errors. Needs to be an int for sys.exit.
|
||||
|
Loading…
Reference in New Issue
Block a user