summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcmd2.py1
-rwxr-xr-xexamples/tab_completion.py4
-rw-r--r--tests/test_completion.py2
3 files changed, 4 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index 5bfef5a9..2403cd75 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -2096,6 +2096,7 @@ class Cmd(cmd.Cmd):
common_prefix = os.path.commonprefix(self.completion_matches)
if matches_delimited:
+ # Check if any of the display matches are part of the tab completion text
display_prefix = os.path.commonprefix(self.display_matches)
# For delimited matches, we check what appears before the display
diff --git a/examples/tab_completion.py b/examples/tab_completion.py
index 93d6c0ef..1419b294 100755
--- a/examples/tab_completion.py
+++ b/examples/tab_completion.py
@@ -8,8 +8,8 @@ import cmd2
from cmd2 import with_argparser, with_argument_list
# List of strings used with flag and index based completion functions
-food_item_strs = ['Pizza', 'Hamburger', 'Ham', 'Potato']
-sport_item_strs = ['Bat', 'Basket', 'Basketball', 'Football']
+food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato']
+sport_item_strs = ['Bat', 'Basket', 'Basketball', 'Football', 'Space Ball']
class TabCompleteExample(cmd2.Cmd):
diff --git a/tests/test_completion.py b/tests/test_completion.py
index cb164a98..5b236130 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -458,7 +458,7 @@ def test_delimiter_completion(cmd2_app):
display_list = list(display_set)
display_list.sort()
- assert display_list == ['otheruser', 'user']
+ assert display_list == ['other user', 'user']
def test_flag_based_completion_single(cmd2_app):
text = 'Pi'