Skip to content

Commit 6ce15fc

Browse files
authored
Fix string index error in tab completion code, fixes #51540 (#51541)
1 parent e9d633f commit 6ce15fc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

stdlib/REPL/src/REPLCompletions.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff
975975
append!(suggestions, complete_keyval(name))
976976
end
977977
if dotpos > 1 && string[dotpos] == '.'
978-
s = string[1:dotpos-1]
978+
s = string[1:prevind(string, dotpos)]
979979
# First see if the whole string up to `pos` is a valid expression. If so, use it.
980980
ex = Meta.parse(s, raise=false, depwarn=false)
981981
if isexpr(ex, :incomplete)

stdlib/REPL/test/replcompletions.jl

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ let ex = quote
2323
end
2424
type_test = Test_x(Test_y(1))
2525
(::Test_y)() = "", ""
26+
unicode_αβγ = Test_y(1)
27+
2628
module CompletionFoo2
2729

2830
end
@@ -253,6 +255,11 @@ let s = "Main.CompletionFoo.type_test.x"
253255
@test s[r] == "x"
254256
end
255257

258+
let s = "Main.CompletionFoo.unicode_αβγ.y"
259+
c, r = test_complete(s)
260+
@test "yy" in c
261+
end
262+
256263
let s = "Main.CompletionFoo.bar.no_val_available"
257264
c, r = test_complete(s)
258265
@test length(c)==0

0 commit comments

Comments
 (0)