Skip to content

Commit a78b81d

Browse files
jakobnissennalimilan
authored andcommitted
Fix string index error in tab completion code, fixes #51540 (#51541)
(cherry picked from commit 6ce15fc)
1 parent 36ed353 commit a78b81d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff
943943
ex = nothing
944944
comp_keywords && append!(suggestions, complete_keyword(name))
945945
if dotpos > 1 && string[dotpos] == '.'
946-
s = string[1:dotpos-1]
946+
s = string[1:prevind(string, dotpos)]
947947
# First see if the whole string up to `pos` is a valid expression. If so, use it.
948948
ex = Meta.parse(s, raise=false, depwarn=false)
949949
if isexpr(ex, :incomplete)

stdlib/REPL/test/replcompletions.jl

Lines changed: 7 additions & 0 deletions
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)