From 0f9d23de639aa5d82c02e751410818f4058390aa Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 17 Aug 2018 07:55:39 +0200 Subject: [PATCH] fix REPL completions not always being unique (#28694) * fix REPLcompletions not unique, fix #28692 (cherry picked from commit cd5e5a38c5565703bb747c6a66b2d23cf3dd5994) --- stdlib/REPL/src/REPL.jl | 6 +++--- stdlib/REPL/test/replcompletions.jl | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 2ce39a860bc51c..977c4af6edb925 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -346,7 +346,7 @@ 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) @@ -354,14 +354,14 @@ function complete_line(c::ShellCompletionProvider, s) 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 diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 2d03dbf925d326..2e8ae033ee0d0c 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -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