Skip to content

Commit 0f9d23d

Browse files
committed
fix REPL completions not always being unique (#28694)
* fix REPLcompletions not unique, fix #28692 (cherry picked from commit cd5e5a3)
1 parent 46d2fde commit 0f9d23d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

stdlib/REPL/src/REPL.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,22 +346,22 @@ function complete_line(c::REPLCompletionProvider, s)
346346
partial = beforecursor(s.input_buffer)
347347
full = LineEdit.input_string(s)
348348
ret, range, should_complete = completions(full, lastindex(partial))
349-
return map(completion_text, ret), partial[range], should_complete
349+
return unique!(map(completion_text, ret)), partial[range], should_complete
350350
end
351351

352352
function complete_line(c::ShellCompletionProvider, s)
353353
# First parse everything up to the current position
354354
partial = beforecursor(s.input_buffer)
355355
full = LineEdit.input_string(s)
356356
ret, range, should_complete = shell_completions(full, lastindex(partial))
357-
return map(completion_text, ret), partial[range], should_complete
357+
return unique!(map(completion_text, ret)), partial[range], should_complete
358358
end
359359

360360
function complete_line(c::LatexCompletions, s)
361361
partial = beforecursor(LineEdit.buffer(s))
362362
full = LineEdit.input_string(s)
363363
ret, range, should_complete = bslash_completions(full, lastindex(partial))[2]
364-
return map(completion_text, ret), partial[range], should_complete
364+
return unique!(map(completion_text, ret)), partial[range], should_complete
365365
end
366366

367367
mutable struct REPLHistoryProvider <: HistoryProvider

stdlib/REPL/test/replcompletions.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ let s = ""
102102
@test s[r] == ""
103103
end
104104

105+
let s = "using REP"
106+
c, r = test_complete(s)
107+
@test count(isequal("REPL"), c) == 1
108+
end
109+
105110
let s = "Comp"
106111
c, r = test_complete(s)
107112
@test "CompletionFoo" in c

0 commit comments

Comments
 (0)