diff --git a/qutebrowser/completion/models/configmodel.py b/qutebrowser/completion/models/configmodel.py index 12a8bdd98..ddda21cf7 100644 --- a/qutebrowser/completion/models/configmodel.py +++ b/qutebrowser/completion/models/configmodel.py @@ -76,7 +76,7 @@ def bind(key, *, info): data = [(cmd_text, cmd.desc, key)] model.add_category(listcategory.ListCategory("Current", data)) - cmdlist = util.get_cmd_completions(include_hidden=True, + cmdlist = util.get_cmd_completions(info, include_hidden=True, include_aliases=True) model.add_category(listcategory.ListCategory("Commands", cmdlist)) return model diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py index f895fc1a4..3244c7bf3 100644 --- a/qutebrowser/completion/models/miscmodels.py +++ b/qutebrowser/completion/models/miscmodels.py @@ -24,20 +24,20 @@ from qutebrowser.utils import objreg, log from qutebrowser.completion.models import completionmodel, listcategory, util -def command(*, info=None): # pylint: disable=unused-argument +def command(*, info): """A CompletionModel filled with non-hidden commands and descriptions.""" model = completionmodel.CompletionModel(column_widths=(20, 60, 20)) - cmdlist = util.get_cmd_completions(include_aliases=True, + cmdlist = util.get_cmd_completions(info, include_aliases=True, include_hidden=False) model.add_category(listcategory.ListCategory("Commands", cmdlist)) return model -def helptopic(*, info=None): # pylint: disable=unused-argument +def helptopic(*, info): """A CompletionModel filled with help topics.""" model = completionmodel.CompletionModel() - cmdlist = util.get_cmd_completions(include_aliases=False, + cmdlist = util.get_cmd_completions(info, include_aliases=False, include_hidden=True, prefix=':') settings = ((opt.name, opt.description) for opt in configdata.DATA.values()) diff --git a/qutebrowser/completion/models/util.py b/qutebrowser/completion/models/util.py index f0ec4ecd0..717355bdf 100644 --- a/qutebrowser/completion/models/util.py +++ b/qutebrowser/completion/models/util.py @@ -21,13 +21,13 @@ from qutebrowser.utils import objreg from qutebrowser.commands import cmdutils -from qutebrowser.config import config -def get_cmd_completions(include_hidden, include_aliases, prefix=''): +def get_cmd_completions(info, include_hidden, include_aliases, prefix=''): """Get a list of completions info for commands, sorted by name. Args: + info: The CompletionInfo. include_hidden: True to include commands annotated with hide=True. include_aliases: True to include command aliases. prefix: String to append to the command name. @@ -36,7 +36,7 @@ def get_cmd_completions(include_hidden, include_aliases, prefix=''): """ assert cmdutils.cmd_dict cmdlist = [] - cmd_to_keys = config.key_instance.get_reverse_bindings_for('normal') + cmd_to_keys = info.keyconf.get_reverse_bindings_for('normal') for obj in set(cmdutils.cmd_dict.values()): hide_debug = obj.debug and not objreg.get('args').debug hide_hidden = obj.hide and not include_hidden @@ -45,7 +45,7 @@ def get_cmd_completions(include_hidden, include_aliases, prefix=''): cmdlist.append((prefix + obj.name, obj.desc, bindings)) if include_aliases: - for name, cmd in config.val.aliases.items(): + for name, cmd in info.config.get('aliases').items(): bindings = ', '.join(cmd_to_keys.get(name, [])) cmdlist.append((name, "Alias for '{}'".format(cmd), bindings)) diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index 2d57c9e69..343bc9eed 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -189,7 +189,7 @@ def info(config_stub, key_config_stub): def test_command_completion(qtmodeltester, cmdutils_stub, configdata_stub, - key_config_stub): + key_config_stub, info): """Test the results of command completion. Validates that: @@ -198,7 +198,7 @@ def test_command_completion(qtmodeltester, cmdutils_stub, configdata_stub, - the binding (if any) is shown in the misc column - aliases are included """ - model = miscmodels.command() + model = miscmodels.command(info=info) model.set_pattern('') qtmodeltester.data_display_may_return_none = True qtmodeltester.check(model) @@ -213,7 +213,7 @@ def test_command_completion(qtmodeltester, cmdutils_stub, configdata_stub, def test_help_completion(qtmodeltester, cmdutils_stub, key_config_stub, - configdata_stub, config_stub): + configdata_stub, config_stub, info): """Test the results of command completion. Validates that: @@ -223,7 +223,7 @@ def test_help_completion(qtmodeltester, cmdutils_stub, key_config_stub, - aliases are not included - only the first line of a multiline description is shown """ - model = miscmodels.helptopic() + model = miscmodels.helptopic(info=info) model.set_pattern('') qtmodeltester.data_display_may_return_none = True qtmodeltester.check(model)