Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of #8989 and #9137 squashed. #9165

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end

function latex_completions(string, pos)
slashpos = rsearch(string, '\\', pos)
if rsearch(string, whitespace_chars, pos) < slashpos
if rsearch(string, whitespace_chars, pos) < slashpos && !(1 < slashpos && (string[slashpos-1]=='\\'))
# latex symbol substitution
s = string[slashpos:pos]
latex = get(latex_symbols, s, "")
Expand Down Expand Up @@ -196,11 +196,14 @@ function completions(string, pos)
(length(string) <= pos || string[pos+1] != '"') # or there's already a " at the cursor.
paths[1] *= "\""
end
return sort(paths), r, success
#Latex symbols can be completed for strings
(success || inc_tag==:cmd) && return sort(paths), r, success
end

ok, ret = latex_completions(string, pos)
ok && return ret
# Make sure that only latex_completions is working on strings
inc_tag==:string && return UTF8String[], 0:-1, false

if inc_tag == :other && string[pos] == '('
endpos = prevind(string, pos)
Expand Down
15 changes: 14 additions & 1 deletion test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ c,r = test_latexcomplete(s)
@test r == 1:length(s)
@test length(c) == 1

# test latex symbol completions in strings should not work when there
# is a backslash in front of `\alpha` because it interferes with path completion on windows
s = "cd(\"path_to_an_empty_folder_should_not_complete_latex\\\\\\alpha"
c,r,res = test_complete(s)
@test length(c) == 0

# test latex symbol completions in strings
s = "\"C:\\\\ \\alpha"
c,r,res = test_complete(s)
@test c[1] == "α"
@test r == 7:12
@test length(c) == 1

## Test completion of packages
#mkp(p) = ((@assert !isdir(p)); mkdir(p))
#temp_pkg_dir() do
Expand Down Expand Up @@ -184,4 +197,4 @@ end
@test file in c
end
rm(tmp)
end
end