summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-21 00:36:12 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-21 00:36:12 -0400
commitd907c7758da0f7671c6378c1cb6138ae807b9bc1 (patch)
tree983c2041311e64764a04414b056651d79fee3165 /cmd2.py
parentb95a21fd9d4ea715edb1b1a913e6e85e0f5e3ade (diff)
downloadcmd2-git-d907c7758da0f7671c6378c1cb6138ae807b9bc1.tar.gz
Updated comments
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd2.py b/cmd2.py
index bdb121cc..464d5827 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1729,6 +1729,7 @@ class Cmd(cmd.Cmd):
# If the token started at begidx, then all we have to do is prepend
# an opening quote to all the completions. Readline will do the rest.
+ # This is always true in the case where there is a shortcut to restore.
if starting_index == orig_begidx:
self.completion_matches = ['"' + match for match in self.completion_matches]
@@ -1770,14 +1771,15 @@ class Cmd(cmd.Cmd):
readline.rl.mode.begidx += 1
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
+ # Check if we need to restore a shortcut in the tab completions
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 has not been set, then set it to self.completion_matches
+ # before we restore the shortcut so the tab completion suggestions that display to
+ # the user don't have the shortcut character.
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
+ # Prepend all tab completions with the shortcut so it doesn't get erased from the command line
self.completion_matches = [shortcut_to_restore + match for match in self.completion_matches]
# Handle single result