Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also complete symbols when completing keyword arguments #15

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/FuzzyCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,12 @@ 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))
repl_completions = @static if VERSION ≥ v"1.10.0-DEV.981"
REPL.REPLCompletions.complete_symbol(nothing, last_word, Returns(true), context_module)
else
REPL.REPLCompletions.complete_symbol(last_word, (mod,x)->true, context_module)
end
append!(suggestions, transform_to_fuzzy_completion.(repl_completions))

return sort!(suggestions, by=completion_text), wordrange
end
Expand All @@ -483,6 +488,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

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

VERSION >= v"1.7" && @testset "inferrability" begin
@inferred FuzzyCompletions.completions("foo", lastindex("foo"), @__MODULE__)
end
Expand Down
Loading