Skip to content

Commit

Permalink
Merge pull request JuliaLang#10336 from dhoegh/fix_#10324
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne committed Mar 2, 2015
2 parents ee29810 + 2b81792 commit 54004c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ function complete_path(path::AbstractString, pos)
end
end
matches = UTF8String[replace(s, r"\s", "\\ ") for s in matches]
return matches, nextind(path, pos - sizeof(prefix) - length(matchall(r" ", prefix))):pos, length(matches) > 0
startpos = pos - endof(prefix) + 1 - length(matchall(r" ", prefix))
# The pos - endof(prefix) + 1 is correct due to `endof(prefix)-endof(prefix)==0`,
# hence we need to add one to get the first index. This is also correct when considering
# pos, because pos is the `endof` a larger string which `endswith(path)==true`.
return matches, startpos:pos, length(matches) > 0
end

# Determines whether method_complete should be tried. It should only be done if
Expand Down
5 changes: 5 additions & 0 deletions test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ let #test that it can auto complete with spaces in file/path
@test r == endof(s)-4:endof(s)
@test "space\\ .file\"" in c
end
# Test for issue #10324
s = "cd(\"$dir_space"
c,r = test_complete(s)
@test r == 5:15
@test s[r] == dir_space
end
rm(dir, recursive=true)
end
Expand Down

0 comments on commit 54004c6

Please sign in to comment.