From b703028411c598bbf1600863a6855145e8231a6d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 28 Dec 2014 22:08:38 +0100 Subject: [PATCH] Clean up and temporarily disable alias completion. Fixes #358. --- qutebrowser/commands/runners.py | 14 ++++---------- qutebrowser/completion/completer.py | 6 +++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py index 820013028..2fa07cb12 100644 --- a/qutebrowser/commands/runners.py +++ b/qutebrowser/commands/runners.py @@ -166,12 +166,11 @@ class CommandRunner(QObject): self._args = [] self._win_id = win_id - def _get_alias(self, text, alias_no_args): + def _get_alias(self, text): """Get an alias from the config. Args: text: The text to parse. - alias_no_args: Whether to apply an alias if there are no arguments. Return: None if no alias was found. @@ -185,16 +184,12 @@ class CommandRunner(QObject): try: new_cmd = '{} {}'.format(alias, parts[1]) except IndexError: - if alias_no_args: - new_cmd = alias - else: - new_cmd = parts[0] + new_cmd = alias if text.endswith(' '): new_cmd += ' ' return new_cmd - def parse(self, text, aliases=True, fallback=False, alias_no_args=True, - keep=False): + def parse(self, text, aliases=True, fallback=False, keep=False): """Split the commandline text into command and arguments. Args: @@ -202,7 +197,6 @@ class CommandRunner(QObject): aliases: Whether to handle aliases. fallback: Whether to do a fallback splitting when the command was unknown. - alias_no_args: Whether to apply an alias if there are no arguments. keep: Whether to keep special chars and whitespace Return: @@ -212,7 +206,7 @@ class CommandRunner(QObject): if not cmdstr and not fallback: raise cmdexc.NoSuchCommandError("No command given") if aliases: - new_cmd = self._get_alias(text, alias_no_args) + new_cmd = self._get_alias(text) if new_cmd is not None: log.commands.debug("Re-parsing with '{}'.".format(new_cmd)) return self.parse(new_cmd, aliases=False, fallback=fallback, diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index 8a1a2fe1a..aeea7dee9 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -326,11 +326,12 @@ class Completer(QObject): if completion.enabled: completion.show() - def split(self, keep=False): + def split(self, keep=False, aliases=False): """Get the text split up in parts. Args: keep: Whether to keep special chars and whitespace. + aliases: Whether to resolve aliases. """ text = self._cmd.text()[len(self._cmd.prefix()):] if not text: @@ -342,8 +343,7 @@ class Completer(QObject): # the whitespace. return [text] runner = runners.CommandRunner(self._win_id) - parts = runner.parse(text, fallback=True, alias_no_args=False, - keep=keep) + parts = runner.parse(text, fallback=True, aliases=aliases, keep=keep) if self._empty_item_idx is not None: log.completion.debug("Empty element queued at {}, " "inserting.".format(self._empty_item_idx))