Skip to content

Commit 7888685

Browse files
authored
Merge pull request #15 from Pangoraw/keyword_sym
Also complete symbols when completing keyword arguments
2 parents a8df7ae + bd11f36 commit 7888685

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/FuzzyCompletions.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ function complete_keyword_argument(partial, last_idx, context_module)
460460
end
461461

462462
suggestions = Completion[KeywordArgumentCompletion(kwarg, partial) for kwarg in kwargs]
463-
# append!(suggestions, complete_symbol(last_word, Returns(true), context_module))
463+
repl_completions = @static if VERSION v"1.10.0-DEV.981"
464+
REPL.REPLCompletions.complete_symbol(nothing, last_word, Returns(true), context_module)
465+
else
466+
REPL.REPLCompletions.complete_symbol(last_word, (mod,x)->true, context_module)
467+
end
468+
append!(suggestions, transform_to_fuzzy_completion.(repl_completions))
464469

465470
return sort!(suggestions, by=completion_text), wordrange
466471
end
@@ -483,6 +488,8 @@ function transform_to_fuzzy_completion(@nospecialize c)
483488
return TextCompletion(c.text)
484489
elseif @static VERSION v"1.9.0-DEV.1034" && isa(c, REPL.REPLCompletions.KeywordArgumentCompletion)
485490
return KeywordArgumentCompletion(c.kwarg)
491+
elseif isa(c, REPL.REPLCompletions.ModuleCompletion)
492+
return ModuleCompletion(c.parent, c.mod)
486493
else
487494
throw("FuzzyCompletions.jl not synced with REPL.REPLCompletions")
488495
end

test/runtests.jl

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ end
9898
@test comp("Mis") == "Missing"
9999
end
100100

101+
VERSION > v"1.9" && @testset "Keyword Argument Completion" begin
102+
@test comp("sin(sin") == "sin"
103+
@test comp("sum(x; dim") == "dims="
104+
@test comp("sum(x, dim") == "dims="
105+
end
106+
101107
VERSION >= v"1.7" && @testset "inferrability" begin
102108
@inferred FuzzyCompletions.completions("foo", lastindex("foo"), @__MODULE__)
103109
end

0 commit comments

Comments
 (0)