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

Fix string index error in tab completion code #51541

Merged
merged 1 commit into from
Oct 2, 2023
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
2 changes: 1 addition & 1 deletion stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff
append!(suggestions, complete_keyval(name))
end
if dotpos > 1 && string[dotpos] == '.'
s = string[1:dotpos-1]
s = string[1:prevind(string, dotpos)]
# First see if the whole string up to `pos` is a valid expression. If so, use it.
ex = Meta.parse(s, raise=false, depwarn=false)
if isexpr(ex, :incomplete)
Expand Down
7 changes: 7 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ let ex = quote
end
type_test = Test_x(Test_y(1))
(::Test_y)() = "", ""
unicode_αβγ = Test_y(1)

module CompletionFoo2

end
Expand Down Expand Up @@ -253,6 +255,11 @@ let s = "Main.CompletionFoo.type_test.x"
@test s[r] == "x"
end

let s = "Main.CompletionFoo.unicode_αβγ.y"
c, r = test_complete(s)
@test "yy" in c
end

let s = "Main.CompletionFoo.bar.no_val_available"
c, r = test_complete(s)
@test length(c)==0
Expand Down