Skip to content

Commit 363d3d1

Browse files
committed
fix crash on capture arg completion
1 parent 228ef69 commit 363d3d1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

apps/elixir_ls_utils/lib/completion_engine.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ defmodule ElixirLS.Utils.CompletionEngine do
184184
# expand_struct_fields_or_local_or_var(code, List.to_string(local_or_var), shell)
185185
expand_local_or_var(List.to_string(local_or_var), env, metadata, cursor_position)
186186

187+
# elixir >= 1.18
188+
{:capture_arg, capture_arg} ->
189+
expand_local_or_var(List.to_string(capture_arg), env, metadata, cursor_position)
190+
187191
{:local_arity, local} ->
188192
expand_local(List.to_string(local), true, env, metadata, cursor_position)
189193

apps/elixir_ls_utils/test/complete_test.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,20 @@ defmodule ElixirLS.Utils.CompletionEngineTest do
470470
assert [] == expand(~c"~r")
471471
end
472472

473+
test "function completion using a capture arg" do
474+
env = %Env{
475+
vars: [
476+
%VarInfo{
477+
name: :"&12",
478+
version: 1
479+
}
480+
]
481+
}
482+
483+
assert [%{name: "&12", type: :variable}] =
484+
expand(~c"&1", env)
485+
end
486+
473487
test "function completion using a variable bound to a module" do
474488
env = %Env{
475489
vars: [

0 commit comments

Comments
 (0)