Skip to content

Commit

Permalink
fix REPL completions not always being unique (#28694)
Browse files Browse the repository at this point in the history
* fix REPLcompletions not unique, fix #28692

(cherry picked from commit cd5e5a3)
  • Loading branch information
KristofferC committed Feb 11, 2019
1 parent 46d2fde commit 0f9d23d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,22 +346,22 @@ function complete_line(c::REPLCompletionProvider, s)
partial = beforecursor(s.input_buffer)
full = LineEdit.input_string(s)
ret, range, should_complete = completions(full, lastindex(partial))
return map(completion_text, ret), partial[range], should_complete
return unique!(map(completion_text, ret)), partial[range], should_complete
end

function complete_line(c::ShellCompletionProvider, s)
# First parse everything up to the current position
partial = beforecursor(s.input_buffer)
full = LineEdit.input_string(s)
ret, range, should_complete = shell_completions(full, lastindex(partial))
return map(completion_text, ret), partial[range], should_complete
return unique!(map(completion_text, ret)), partial[range], should_complete
end

function complete_line(c::LatexCompletions, s)
partial = beforecursor(LineEdit.buffer(s))
full = LineEdit.input_string(s)
ret, range, should_complete = bslash_completions(full, lastindex(partial))[2]
return map(completion_text, ret), partial[range], should_complete
return unique!(map(completion_text, ret)), partial[range], should_complete
end

mutable struct REPLHistoryProvider <: HistoryProvider
Expand Down
5 changes: 5 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ let s = ""
@test s[r] == ""
end

let s = "using REP"
c, r = test_complete(s)
@test count(isequal("REPL"), c) == 1
end

let s = "Comp"
c, r = test_complete(s)
@test "CompletionFoo" in c
Expand Down

0 comments on commit 0f9d23d

Please sign in to comment.