Skip to content

Commit

Permalink
Complete Symbols from REPL when completing keyword arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangoraw committed Aug 17, 2023
1 parent b0a5b5e commit 29e8024
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/FuzzyCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ function complete_keyword_argument(partial, last_idx, context_module)
end

suggestions = Completion[KeywordArgumentCompletion(kwarg, partial) for kwarg in kwargs]
# append!(suggestions, complete_symbol(last_word, Returns(true), context_module))
append!(suggestions,
transform_to_fuzzy_completion.(REPL.REPLCompletions.complete_symbol(last_word, (mod,x)->true, context_module)))

return sort!(suggestions, by=completion_text), wordrange
end
Expand All @@ -433,6 +434,8 @@ function transform_to_fuzzy_completion(@nospecialize c)
return TextCompletion(c.text)
elseif @static VERSION v"1.9.0-DEV.1034" && isa(c, REPL.REPLCompletions.KeywordArgumentCompletion)
return KeywordArgumentCompletion(c.kwarg)
elseif isa(c, REPL.REPLCompletions.ModuleCompletion)
return ModuleCompletion(c.parent, c.mod)
else
throw("FuzzyCompletions.jl not synced with REPL.REPLCompletions")
end
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ end
@test comp("Mis") == "Missing"
end

@testset "Keyword Argument Completion" begin
@test comp("sin(sin") == "sin"
@test comp("sum(x; dim") == "dims="
@test comp("sum(x, dim") == "dims="
end

@testset "inferrability" begin
@inferred FuzzyCompletions.completions("foo", lastindex("foo"), @__MODULE__)
end
Expand Down

0 comments on commit 29e8024

Please sign in to comment.