diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index a6cb12ab05211..debe568b25f64 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -997,6 +997,17 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff ex = Meta.parse(lookup_name, raise=false, depwarn=false) end isexpr(ex, :incomplete) && (ex = nothing) + elseif isexpr(ex, :call) && length(ex.args) > 1 + isinfix = s[end] != ')' + # A complete call expression that does not finish with ')' is an infix call. + if !isinfix + # Handle infix call argument completion of the form bar + foo(qux). + frange, end_of_identifier = find_start_brace(@view s[1:prevind(s, end)]) + isinfix = Meta.parse(@view(s[frange[1]:end]), raise=false, depwarn=false) == ex.args[end] + end + if isinfix + ex = ex.args[end] + end end end append!(suggestions, complete_symbol(ex, name, ffunc, context_module)) diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 501193b15e2f4..c5a2d1c8e006e 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -25,6 +25,7 @@ let ex = quote (::Test_y)() = "", "" unicode_αβγ = Test_y(1) + Base.:(+)(x::Test_x, y::Test_y) = Test_x(Test_y(x.xx.yy + y.yy)) module CompletionFoo2 end @@ -1889,3 +1890,17 @@ let s = "Issue49892(fal" @test n in c end end + +# issue #51194 +for (s, compl) in (("2*CompletionFoo.nam", "named"), + (":a isa CompletionFoo.test!1", "test!12"), + ("-CompletionFoo.Test_y(3).", "yy"), + ("99 ⨷⁻ᵨ⁷ CompletionFoo.type_test.", "xx"), + ("CompletionFoo.type_test + CompletionFoo.Test_y(2).", "yy"), + ("(CompletionFoo.type_test + CompletionFoo.Test_y(2)).", "xx"), + ("CompletionFoo.type_test + CompletionFoo.unicode_αβγ.", "yy"), + ("(CompletionFoo.type_test + CompletionFoo.unicode_αβγ).", "xx"), + ("foo'CompletionFoo.test!1", "test!12")) + c, r = test_complete(s) + @test only(c) == compl +end