@@ -382,6 +382,15 @@ def test_path_completion_doesnt_match_wildcards(request):
382382 # Currently path completion doesn't accept wildcards, so will always return empty results
383383 assert path_complete (text , line , begidx , endidx ) == []
384384
385+ def test_path_completion_invalid_syntax ():
386+ # Test a missing separator between a ~ and path
387+ text = ''
388+ line = 'shell fake ~Desktop'
389+ endidx = len (line )
390+ begidx = endidx - len (text )
391+
392+ assert path_complete (text , line , begidx , endidx ) == []
393+
385394def test_path_completion_just_tilde ():
386395 # Run path with just a tilde
387396 text = ''
@@ -403,14 +412,14 @@ def test_path_completion_user_expansion():
403412
404413 line = 'shell {} ~{}' .format (cmd , os .path .sep )
405414 endidx = len (line )
406- begidx = endidx
415+ begidx = endidx - len ( text )
407416 completions_tilde_slash = path_complete (text , line , begidx , endidx )
408417
409418 # Run path complete on the user's home directory
410419 user_dir = os .path .expanduser ('~' ) + os .path .sep
411420 line = 'shell {} {}' .format (cmd , user_dir )
412421 endidx = len (line )
413- begidx = endidx
422+ begidx = endidx - len ( text )
414423 completions_home = path_complete (text , line , begidx , endidx )
415424
416425 # Verify that the results are the same in both cases
0 commit comments