@@ -382,6 +382,15 @@ def test_path_completion_doesnt_match_wildcards(request):
382
382
# Currently path completion doesn't accept wildcards, so will always return empty results
383
383
assert path_complete (text , line , begidx , endidx ) == []
384
384
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
+
385
394
def test_path_completion_just_tilde ():
386
395
# Run path with just a tilde
387
396
text = ''
@@ -403,14 +412,14 @@ def test_path_completion_user_expansion():
403
412
404
413
line = 'shell {} ~{}' .format (cmd , os .path .sep )
405
414
endidx = len (line )
406
- begidx = endidx
415
+ begidx = endidx - len ( text )
407
416
completions_tilde_slash = path_complete (text , line , begidx , endidx )
408
417
409
418
# Run path complete on the user's home directory
410
419
user_dir = os .path .expanduser ('~' ) + os .path .sep
411
420
line = 'shell {} {}' .format (cmd , user_dir )
412
421
endidx = len (line )
413
- begidx = endidx
422
+ begidx = endidx - len ( text )
414
423
completions_home = path_complete (text , line , begidx , endidx )
415
424
416
425
# Verify that the results are the same in both cases
0 commit comments