Skip to content

Commit

Permalink
Merge pull request #9143 from dhoegh/fix_shell_completion_error
Browse files Browse the repository at this point in the history
Fix error regarding unescape_string introduced by #8838
  • Loading branch information
tkelman committed Nov 25, 2014
2 parents b97ec83 + 6e0e9d6 commit dcd9ac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ function completions(string, pos)
partial = string[1:pos]
inc_tag = Base.incomplete_tag(parse(partial , raise=false))
if inc_tag in [:cmd, :string]
m = match(r"[\t\n\r\"'`@\$><=;|&\{]| (?!\\)",reverse(partial))
startpos = length(partial)-(m == nothing ? 1 : m.offset) + 2
m = match(r"[\t\n\r\"'`@\$><=;|&\{]| (?!\\)", reverse(partial))
startpos = length(partial) - (m == nothing ? 1 : m.offset) + 2
r = startpos:pos
paths, r, success = complete_path(unescape_string(string[r]), 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(unescape_string(string[startpos:start(r)-1] * paths[1])) && # except if it's a directory
!isdir(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
4 changes: 4 additions & 0 deletions test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ c,r,res = test_complete(s)
@test r == 7:12
@test length(c) == 1

# `cd("C:\U should not make the repl crash due to escaping see comment #9137
s = "cd(\"C:\\U"
c,r,res = test_complete(s)

## Test completion of packages
#mkp(p) = ((@assert !isdir(p)); mkdir(p))
#temp_pkg_dir() do
Expand Down

0 comments on commit dcd9ac2

Please sign in to comment.