summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-04-14 23:02:04 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-04-14 23:02:04 -0400
commitfa5c7ad71b36208e6bd6d54fe18411861e6a3fb6 (patch)
tree106e17b3d56612b5430083e011859e9178fa7102 /cmd2.py
parent9393380ed3068c8dc790d1dbcaa55f10e40eb4b5 (diff)
downloadcmd2-git-fa5c7ad71b36208e6bd6d54fe18411861e6a3fb6.tar.gz
Improving documentation
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/cmd2.py b/cmd2.py
index 996a628c..0ba98106 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -2075,27 +2075,34 @@ class Cmd(cmd.Cmd):
display_matches_set = set(self.display_matches)
self.display_matches = list(display_matches_set)
- # If self.display_matches is empty, then set it to self.completion_matches
- # before we alter them. That way the suggestions will reflect how we parsed
- # the token being completed and not how readline did.
- display_matches_delimited = True
- if not self.display_matches:
- display_matches_delimited = False
+ # Check if display_matches has been used. If so, then matches
+ # on delimited strings like paths was done.
+ if self.display_matches:
+ matches_delimited = True
+ else:
+ matches_delimited = False
+
+ # Since self.display_matches is empty, then set it to self.completion_matches
+ # before we alter them. That way the suggestions will reflect how we parsed
+ # the token being completed and not how readline did.
self.display_matches = copy.copy(self.completion_matches)
# Check if we need to add an opening quote
if not unclosed_quote:
+ add_quote = False
+
+ # This is the tab completion text that will appear on the command line.
common_prefix = os.path.commonprefix(self.completion_matches)
- add_quote = False
- if display_matches_delimited:
+ if matches_delimited:
display_prefix = os.path.commonprefix(self.display_matches)
if (' ' in common_prefix) or (display_prefix and ' ' in ''.join(self.display_matches)):
add_quote = True
- else:
- if common_prefix and ' ' in ''.join(self.completion_matches):
- add_quote = True
+
+ # If there is a tab completion and any match has a space, then add an opening quote
+ elif common_prefix and ' ' in ''.join(self.completion_matches):
+ add_quote = True
if add_quote:
# Figure out what kind of quote to add and save it as the unclosed_quote