From 3140fe01ea00a50bdb48b17bca0c5dc513c2ca70 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Sun, 15 Apr 2018 01:06:29 -0400 Subject: Updated comments and examples --- cmd2.py | 1 + examples/tab_completion.py | 4 ++-- tests/test_completion.py | 2 +- 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' -- cgit v1.2.1