Merge branch 'modifcation-for-issue-1386' of https://github.com/adamwethington7/qutebrowser into adamwethington7-modifcation-for-issue-1386

This commit is contained in:
Florian Bruhin 2016-06-06 15:44:56 +02:00
commit 5b396dab26

View File

@ -172,6 +172,9 @@ class CommandRunner(QObject):
log.commands.debug("Re-parsing with '{}'.".format(new_cmd))
return self.parse(new_cmd, aliases=False, fallback=fallback,
keep=keep)
cmdstr = self._completion_match(cmdstr)
try:
cmd = cmdutils.cmd_dict[cmdstr]
except KeyError:
@ -196,6 +199,23 @@ class CommandRunner(QObject):
cmdline = [cmdstr] + args[:]
return ParseResult(cmd=cmd, args=args, cmdline=cmdline, count=count)
def _completion_match(self, cmdstr):
"""Replace cmdstr with a matching completion if there's only one match.
Args:
cmdstr: The string representing the entered command so far
Return:
cmdstr modified to the matching completion or unmodified
"""
matches = []
for valid_command in cmdutils.cmd_dict.keys():
if valid_command.find(cmdstr) == 0:
matches.append(valid_command)
if len(matches) == 1:
cmdstr = matches[0]
return cmdstr
def _split_args(self, cmd, argstr, keep):
"""Split the arguments from an arg string.