Skip to content

Commit

Permalink
Merge pull request #15 from Pangoraw/keyword_sym
Browse files Browse the repository at this point in the history
Also complete symbols when completing keyword arguments
  • Loading branch information
pfitzseb authored Mar 13, 2024
2 parents a8df7ae + bd11f36 commit 7888685
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 7888685

Please sign in to comment.