diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index 490bb41178adf..113aae6721cb6 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -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 diff --git a/test/replcompletions.jl b/test/replcompletions.jl index e70c5828f2e49..c1c29cb88aaa5 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -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