summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-20 17:55:18 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-20 17:55:18 -0400
commit7c563413767ecc50ad459517004f2ff5d694977a (patch)
treec7abae3d9fcd6829cf9771221b6fba5850dc9608 /cmd2.py
parent8ba1e4e723982918ccd179dd1ae008daea20c619 (diff)
downloadcmd2-git-7c563413767ecc50ad459517004f2ff5d694977a.tar.gz
Fixed some unit tests
Diffstat (limited to 'cmd2.py')
-rw-r--r--cmd2.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/cmd2.py b/cmd2.py
index 07600add..c81946b3 100644
--- a/cmd2.py
+++ b/cmd2.py
@@ -1578,12 +1578,12 @@ class Cmd(cmd.Cmd):
# If the line starts with a shortcut that has no break between the search text,
# then the text variable will start with the shortcut if its not a completer delimiter
- text_shortcut = ''
+ shortcut_to_restore = ''
if begidx == 0:
for (shortcut, expansion) in self.shortcuts:
if text.startswith(shortcut):
# Save the shortcut to adjust the line later
- text_shortcut = shortcut
+ shortcut_to_restore = shortcut
# Adjust text and where it begins
text = text[len(shortcut):]
@@ -1726,14 +1726,14 @@ class Cmd(cmd.Cmd):
readline.rl.mode.endidx += 1
# If a shortcut started text, then we need to make sure it doesn't get erased on the command line
- if text_shortcut:
+ if shortcut_to_restore:
# If matches_to_display has not been set, then display the actual matches
# that do not show the shortcut character at the beginning of each match.
if matches_to_display is None:
set_matches_to_display(self.completion_matches)
# Given readline the restored shortcut character since that's what its expecting
- self.completion_matches = [text_shortcut + match for match in self.completion_matches]
+ self.completion_matches = [shortcut_to_restore + match for match in self.completion_matches]
# Handle single result
if len(self.completion_matches) == 1:
@@ -2637,8 +2637,11 @@ Usage: Usage: unalias [-a] name [name ...]
# Get the index of the token being completed
index = len(tokens) - 1
+ if index < shell_cmd_index:
+ return []
+
# Complete the shell command
- if index == shell_cmd_index:
+ elif index == shell_cmd_index:
completion_token = tokens[index]
@@ -2665,7 +2668,7 @@ Usage: Usage: unalias [-a] name [name ...]
return path_complete(text, line, begidx, endidx, dir_exe_only=True)
# We are past the shell command, so do path completion
- elif index > shell_cmd_index:
+ else:
return path_complete(text, line, begidx, endidx)
def cmd_with_subs_completer(self, text, line, begidx, endidx, base):