File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -915,6 +915,27 @@ def test_add_opening_quote_nothing_added(cmd2_app) -> None:
915915 assert not completions ._quote_char
916916
917917
918+ def test_word_break_in_quote (cmd2_app ) -> None :
919+ """Test case where search text has a space and is in a quote."""
920+
921+ # Cmd2Completer still performs word breaks after a quote. Since space
922+ # is word-break character, it says the search text starts at 'S' and
923+ # passes that to the complete() function.
924+ text = 'S'
925+ line = 'test_basic "Ham S'
926+ endidx = len (line )
927+ begidx = endidx - len (text )
928+
929+ # Since the search text is within an opening quote, cmd2 will rebuild
930+ # the whole search token as 'Ham S' and match it to 'Ham Sandwich'.
931+ # But before it returns the results back to Cmd2Completer, it removes
932+ # anything before the original search text since this is what Cmd2Completer
933+ # expects. Therefore the actual match text is 'Sandwich'.
934+ expected = ["Sandwich" ]
935+ completions = cmd2_app .complete (text , line , begidx , endidx )
936+ assert completions .to_strings () == Completions .from_values (expected ).to_strings ()
937+
938+
918939def test_no_completer (cmd2_app ) -> None :
919940 text = ''
920941 line = f'test_no_completer { text } '
You can’t perform that action at this time.
0 commit comments