Skip to content

Commit e1538ed

Browse files
authored
fuzzy matching (#491)
* bump elixir_sense * prepare tests for fuzzy matching
1 parent d87c5e5 commit e1538ed

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

apps/language_server/test/providers/completion_test.exs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,16 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
471471
setup do
472472
text = """
473473
defmodule MyModule do
474-
def add(a, b), do: a + b
474+
def add_2_numbers(a, b), do: a + b
475475
476476
def dummy_function() do
477-
ad
478-
# ^
477+
ad2n
478+
# ^
479479
end
480480
end
481481
"""
482482

483-
%{text: text, location: {4, 6}}
483+
%{text: text, location: {4, 8}}
484484
end
485485

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

508-
assert item["insertText"] == "add"
508+
assert item["insertText"] == "add_2_numbers"
509509
assert item["command"] == nil
510510

511511
opts =
512512
Keyword.merge(@supports,
513513
snippets_supported: false,
514-
locals_without_parens: MapSet.new(add: 2)
514+
locals_without_parens: MapSet.new(add_2_numbers: 2)
515515
)
516516

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

519-
assert item["insertText"] == "add "
519+
assert item["insertText"] == "add_2_numbers "
520520
assert item["command"] == @signature_command
521521
end
522522

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

532-
assert item["insertText"] == "add("
532+
assert item["insertText"] == "add_2_numbers("
533533
assert item["command"] == @signature_command
534534
end
535535

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

545-
assert item["insertText"] == "add(${1:a}, ${2:b})"
545+
assert item["insertText"] == "add_2_numbers(${1:a}, ${2:b})"
546546
assert item["command"] == nil
547547
end
548548

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

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

557-
assert item["insertText"] == "add($1)$0"
557+
assert item["insertText"] == "add_2_numbers($1)$0"
558558
assert item["command"] == @signature_command
559559
end
560560

561561
test "with snippets/signature support, before valid arg, do not close parens" do
562562
text = """
563563
defmodule MyModule do
564-
def add(a, b), do: a + b
564+
def add_2_numbers(a, b), do: a + b
565565
566566
def dummy_function() do
567-
ad100
568-
# ^
567+
ad2n100
568+
# ^
569569
end
570570
end
571571
"""
572572

573-
{line, char} = {4, 6}
573+
{line, char} = {4, 8}
574574
TestUtils.assert_has_cursor_char(text, line, char)
575575

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

578-
assert item["insertText"] == "add("
578+
assert item["insertText"] == "add_2_numbers("
579579
assert item["command"] == @signature_command
580580
end
581581

582582
test "function in :locals_without_parens doesn't complete with args if there's text after cursor" do
583583
text = """
584584
defmodule MyModule do
585-
def add(a, b), do: a + b
585+
def add_2_numbers(a, b), do: a + b
586586
587587
def dummy_function() do
588-
ad 100
589-
# ^
588+
ad2n 100
589+
# ^
590590
end
591591
end
592592
"""
593593

594-
{line, char} = {4, 6}
594+
{line, char} = {4, 8}
595595
TestUtils.assert_has_cursor_char(text, line, char)
596596

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

600-
assert item["insertText"] == "add"
600+
assert item["insertText"] == "add_2_numbers"
601601
assert item["command"] == @signature_command
602602
end
603603

mix.lock

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

0 commit comments

Comments
 (0)