Implement "Current" completion for bind.
When binding a key, the first row will be the current binding if the key is already bound. This should make it easier for users to tell when they are binding a key that is already bound, and what it is bound to.
This commit is contained in:
parent
1e489325c4
commit
c1f5e77fc6
@ -120,14 +120,20 @@ def buffer():
|
|||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
||||||
def bind(_key):
|
def bind(key):
|
||||||
"""A CompletionModel filled with all bindable commands and descriptions.
|
"""A CompletionModel filled with all bindable commands and descriptions.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
_key: the key being bound.
|
key: the key being bound.
|
||||||
"""
|
"""
|
||||||
# TODO: offer a 'Current binding' completion based on the key.
|
|
||||||
model = completionmodel.CompletionModel(column_widths=(20, 60, 20))
|
model = completionmodel.CompletionModel(column_widths=(20, 60, 20))
|
||||||
|
cmd_name = objreg.get('key-config').get_bindings_for('normal').get(key)
|
||||||
|
|
||||||
|
if cmd_name:
|
||||||
|
cmd = cmdutils.cmd_dict.get(cmd_name)
|
||||||
|
data = [(cmd_name, cmd.desc, key)]
|
||||||
|
model.add_category(listcategory.ListCategory("Current", data))
|
||||||
|
|
||||||
cmdlist = _get_cmd_completions(include_hidden=True, include_aliases=True)
|
cmdlist = _get_cmd_completions(include_hidden=True, include_aliases=True)
|
||||||
model.add_category(listcategory.ListCategory("Commands", cmdlist))
|
model.add_category(listcategory.ListCategory("Commands", cmdlist))
|
||||||
return model
|
return model
|
||||||
|
@ -567,6 +567,9 @@ def test_bind_completion(qtmodeltester, monkeypatch, stubs, config_stub,
|
|||||||
qtmodeltester.check(model)
|
qtmodeltester.check(model)
|
||||||
|
|
||||||
_check_completions(model, {
|
_check_completions(model, {
|
||||||
|
"Current": [
|
||||||
|
('stop', 'stop qutebrowser', 's'),
|
||||||
|
],
|
||||||
"Commands": [
|
"Commands": [
|
||||||
('drop', 'drop all user data', ''),
|
('drop', 'drop all user data', ''),
|
||||||
('hide', '', ''),
|
('hide', '', ''),
|
||||||
|
Loading…
Reference in New Issue
Block a user