Skip to content

Commit

Permalink
Merge pull request JuliaLang#11440 from JuliaLang/brj/user-path-compl…
Browse files Browse the repository at this point in the history
…etion-test

Add a test for user path completion.
  • Loading branch information
jakebolewski committed May 26, 2015
2 parents 70dd6a8 + 216d7fe commit 0855ec9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function completions(string, pos)
paths, r, success = complete_path(replace(string[r], r"\\ ", " "), pos)
if inc_tag == :string &&
length(paths) == 1 && # Only close if there's a single choice,
!isdir(replace(string[startpos:start(r)-1] * paths[1], r"\\ ", " ")) && # except if it's a directory
!isdir(expanduser(replace(string[startpos:start(r)-1] * paths[1], r"\\ ", " "))) && # except if it's a directory
(length(string) <= pos || string[pos+1] != '"') # or there's already a " at the cursor.
paths[1] *= "\""
end
Expand Down
13 changes: 13 additions & 0 deletions test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,19 @@ c, r, res = test_scomplete(s)
@test "Pkg" in c
@test r == 6:7
@test s[r] == "Pk"

# Tests homedir expansion
let
path = homedir()
dir = joinpath(path, "tmpfoobar")
mkdir(dir)
s = "\"~/tmpfoob"
c,r = test_complete(s)
@test "tmpfoobar/" in c
@test r == 4:10
@test s[r] == "tmpfoob"
rm(dir)
end
end

let #test that it can auto complete with spaces in file/path
Expand Down

0 comments on commit 0855ec9

Please sign in to comment.