@@ -1455,6 +1455,43 @@ 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+
1468+ # Completion at end of line should work
1469+ let (c, r, res) = test_complete (" \" $(path)$(sep) foo" )
1470+ @test res
1471+ @test length (c) == 2
1472+ @test " $(path)$(sep) foo_dir$(sep) " in c
1473+ @test " $(path)$(sep) foo_file.txt" in c
1474+ end
1475+
1476+ # Completion in middle of line should also work (regression in 1.12)
1477+ let (c, r, res) = test_complete_pos (" \" $(path)$(sep) foo|$(sep) bar.toml\" " )
1478+ @test res
1479+ @test length (c) == 2
1480+ @test " $(path)$(sep) foo_dir$(sep) " in c
1481+ @test " $(path)$(sep) foo_file.txt" in c
1482+ # Check that the range covers only the part before the cursor
1483+ @test findfirst (" $(sep) bar" , " \" $(path)$(sep) foo$(sep) bar.toml\" " )[1 ] - 1 in r
1484+ end
1485+
1486+ # Completion in middle of function call with trailing arguments
1487+ let (c, r, res) = test_complete_pos (" run_something(\" $(path)$(sep) foo|$(sep) bar.toml\" ; kwarg=true)" )
1488+ @test res
1489+ @test length (c) == 2
1490+ @test " $(path)$(sep) foo_dir$(sep) " in c
1491+ @test " $(path)$(sep) foo_file.txt" in c
1492+ end
1493+ end
1494+
14581495if Sys. iswindows ()
14591496 tmp = tempname ()
14601497 touch (tmp)
0 commit comments