@@ -1455,6 +1455,45 @@ let (c, r) = test_complete("cd(\"folder_do_not_exist_77/file")
14551455 @test length (c) == 0
14561456end
14571457
1458+ # Test path completion in the middle of a line (issue #60050)
1459+ mktempdir () do path
1460+ # Create test directory structure
1461+ foo_dir = joinpath (path, " foo_dir" )
1462+ mkpath (foo_dir)
1463+ touch (joinpath (path, " foo_file.txt" ))
1464+
1465+ # On Windows, use backslashes; on Unix, use forward slashes
1466+ sep = Sys. iswindows () ? " \\\\ " : " /"
1467+ # On Windows, completion results have escaped backslashes
1468+ path_expected = Sys. iswindows () ? replace (path, " \\ " => " \\\\ " ) : path
1469+
1470+ # Completion at end of line should work
1471+ let (c, r, res) = test_complete (" \" $(path)$(sep) foo" )
1472+ @test res
1473+ @test length (c) == 2
1474+ @test " $(path_expected)$(sep) foo_dir$(sep) " in c
1475+ @test " $(path_expected)$(sep) foo_file.txt" in c
1476+ end
1477+
1478+ # Completion in middle of line should also work (regression in 1.12)
1479+ let (c, r, res) = test_complete_pos (" \" $(path)$(sep) foo|$(sep) bar.toml\" " )
1480+ @test res
1481+ @test length (c) == 2
1482+ @test " $(path_expected)$(sep) foo_dir$(sep) " in c
1483+ @test " $(path_expected)$(sep) foo_file.txt" in c
1484+ # Check that the range covers only the part before the cursor
1485+ @test findfirst (" $(sep) bar" , " \" $(path)$(sep) foo$(sep) bar.toml\" " )[1 ] - 1 in r
1486+ end
1487+
1488+ # Completion in middle of function call with trailing arguments
1489+ let (c, r, res) = test_complete_pos (" run_something(\" $(path)$(sep) foo|$(sep) bar.toml\" ; kwarg=true)" )
1490+ @test res
1491+ @test length (c) == 2
1492+ @test " $(path_expected)$(sep) foo_dir$(sep) " in c
1493+ @test " $(path_expected)$(sep) foo_file.txt" in c
1494+ end
1495+ end
1496+
14581497if Sys. iswindows ()
14591498 tmp = tempname ()
14601499 touch (tmp)
0 commit comments