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

fuzzy matching #491

Merged
merged 2 commits into from
Feb 28, 2021
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
42 changes: 21 additions & 21 deletions apps/language_server/test/providers/completion_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,16 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
setup do
text = """
defmodule MyModule do
def add(a, b), do: a + b
def add_2_numbers(a, b), do: a + b

def dummy_function() do
ad
# ^
ad2n
# ^
end
end
"""

%{text: text, location: {4, 6}}
%{text: text, location: {4, 8}}
end

test "setting 'signature_after_complete'", context do
Expand All @@ -505,18 +505,18 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
opts = Keyword.merge(@supports, snippets_supported: false, signature_help_supported: false)
{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, opts)

assert item["insertText"] == "add"
assert item["insertText"] == "add_2_numbers"
assert item["command"] == nil

opts =
Keyword.merge(@supports,
snippets_supported: false,
locals_without_parens: MapSet.new(add: 2)
locals_without_parens: MapSet.new(add_2_numbers: 2)
)

{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, opts)

assert item["insertText"] == "add "
assert item["insertText"] == "add_2_numbers "
assert item["command"] == @signature_command
end

Expand All @@ -529,7 +529,7 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
opts = Keyword.merge(@supports, snippets_supported: false)
{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, opts)

assert item["insertText"] == "add("
assert item["insertText"] == "add_2_numbers("
assert item["command"] == @signature_command
end

Expand All @@ -542,7 +542,7 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
opts = Keyword.merge(@supports, signature_help_supported: false)
{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, opts)

assert item["insertText"] == "add(${1:a}, ${2:b})"
assert item["insertText"] == "add_2_numbers(${1:a}, ${2:b})"
assert item["command"] == nil
end

Expand All @@ -554,50 +554,50 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do

{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, @supports)

assert item["insertText"] == "add($1)$0"
assert item["insertText"] == "add_2_numbers($1)$0"
assert item["command"] == @signature_command
end

test "with snippets/signature support, before valid arg, do not close parens" do
text = """
defmodule MyModule do
def add(a, b), do: a + b
def add_2_numbers(a, b), do: a + b

def dummy_function() do
ad100
# ^
ad2n100
# ^
end
end
"""

{line, char} = {4, 6}
{line, char} = {4, 8}
TestUtils.assert_has_cursor_char(text, line, char)

{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, @supports)

assert item["insertText"] == "add("
assert item["insertText"] == "add_2_numbers("
assert item["command"] == @signature_command
end

test "function in :locals_without_parens doesn't complete with args if there's text after cursor" do
text = """
defmodule MyModule do
def add(a, b), do: a + b
def add_2_numbers(a, b), do: a + b

def dummy_function() do
ad 100
# ^
ad2n 100
# ^
end
end
"""

{line, char} = {4, 6}
{line, char} = {4, 8}
TestUtils.assert_has_cursor_char(text, line, char)

opts = Keyword.merge(@supports, locals_without_parens: MapSet.new(add: 2))
opts = Keyword.merge(@supports, locals_without_parens: MapSet.new(add_2_numbers: 2))
{:ok, %{"items" => [item]}} = Completion.completion(text, line, char, opts)

assert item["insertText"] == "add"
assert item["insertText"] == "add_2_numbers"
assert item["command"] == @signature_command
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
"docsh": {:hex, :docsh, "0.7.2", "f893d5317a0e14269dd7fe79cf95fb6b9ba23513da0480ec6e77c73221cae4f2", [:rebar3], [{:providers, "1.8.1", [hex: :providers, repo: "hexpm", optional: false]}], "hexpm", "4e7db461bb07540d2bc3d366b8513f0197712d0495bb85744f367d3815076134"},
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "28f8467a349c6ed004aac66a2e8d7020cdde2e0d", []},
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "6c70be73b59d049e7d46eba520f29e1d767f2f4a", []},
"erl2ex": {:git, "https://github.com/dazuma/erl2ex.git", "244c2d9ed5805ef4855a491d8616b8842fef7ca4", []},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"forms": {:hex, :forms, "0.0.1", "45f3b10b6f859f95f2c2c1a1de244d63855296d55ed8e93eb0dd116b3e86c4a6", [:rebar3], [], "hexpm", "530f63ed8ed5a171f744fc75bd69cb2e36496899d19dbef48101b4636b795868"},
Expand Down