@@ -731,13 +731,13 @@ def test_add_opening_quote_delimited_nothing_added(cmd2_app):
731731 cmd2_app .display_matches == expected_display
732732
733733def test_add_opening_quote_delimited_quote_added (cmd2_app ):
734- text = '/home/oth '
734+ text = '/home/user/fi '
735735 line = 'test_delimited {}' .format (text )
736736 endidx = len (line )
737737 begidx = endidx - len (text )
738738
739- expected_prefix = '"/home/other user/'
740- expected_display = [ 'maps ' , 'tests' ]
739+ expected_prefix = '"/home/user/file '
740+ expected_display = sorted ([ 'file.txt ' , 'file space.txt' ])
741741
742742 first_match = complete_tester (text , line , begidx , endidx , cmd2_app )
743743 assert first_match is not None and \
@@ -759,6 +759,21 @@ def test_add_opening_quote_delimited_text_is_common_prefix(cmd2_app):
759759 os .path .commonprefix (cmd2_app .completion_matches ) == expected_prefix and \
760760 cmd2_app .display_matches == expected_display
761761
762+ def test_add_opening_quote_delimited_space_in_prefix (cmd2_app ):
763+ # This test when a space appears before the part of the string that is the display match
764+ text = '/home/oth'
765+ line = 'test_delimited {}' .format (text )
766+ endidx = len (line )
767+ begidx = endidx - len (text )
768+
769+ expected_prefix = '"/home/other user/'
770+ expected_display = ['maps' , 'tests' ]
771+
772+ first_match = complete_tester (text , line , begidx , endidx , cmd2_app )
773+ assert first_match is not None and \
774+ os .path .commonprefix (cmd2_app .completion_matches ) == expected_prefix and \
775+ cmd2_app .display_matches == expected_display
776+
762777class SubcommandsExample (cmd2 .Cmd ):
763778 """
764779 Example cmd2 application where we a base command which has a couple subcommands
0 commit comments