lexical-lsp / lexical

Lexical is a next-generation elixir language server
776 stars 77 forks source link

Account for blocks in maybe_move_cursor_to_next_token #750

Closed dvic closed 1 month ago

dvic commented 1 month ago

Turns out #747 was indeed a local config issue (lexical was compiled with a more recent elixir/erlang version than the project).

However, the error was hiding the true underlying issue:

2024-05-22T20:43:39.721 helix_lsp::transport [ERROR] lexical <- InternalError: ** (ErlangError) Erlang error: {:exception, {:badmatch, #Sourceror.Zipper<
    [{{:__block__, [format: :keyword, line: 848, column: 15], [:enforce]}, {:__block__, [line: 848, column: 24], [true]}}, {{:__block__, [format: :keyword, line: 848, column: 30], [:module]}, {:__aliases__, [last: [line: 848, column: 38], line: 848, column: 38], [:CreatedContract]}}]
    #...
  >}, [{LXical.RemoteControl.CodeIntelligence.Definition, :maybe_move_cursor_to_next_token, 4, [file: ~c"lib/lexical/remote_control/code_intelligence/definition.ex", line: 130]}, {LXical.RemoteControl.CodeIntelligence.Definition, :parse_location, 2, [file: ~c"lib/lexical/remote_control/code_intelligence/definition.ex", line: 111]}, {LXical.RemoteControl.CodeIntelligence.Definition, :definition, 2, []}]}
    (kernel 9.1) erpc.erl:702: :erpc.call/5
    (lx_server 0.5.0) lib/lexical/server/provider/handlers/go_to_definition.ex:9: LXical.Server.Provider.Handlers.GoToDefinition.handle/2
    (lx_server 0.5.0) lib/lexical/server/provider/queue.ex:99: anonymous fn/2 in LXical.Server.Provider.Queue.State.as_task/2
    (elixir 1.15.6) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.15.6) lib/task/supervised.ex:36: Task.Supervised.reply/4
scohen commented 1 month ago

@dvic mind sharing the code and cursor position that caused this issue?

dvic commented 1 month ago

@dvic mind sharing the code and cursor position that caused this issue?

It's this position:

image

Is this enough context to reproduce it?

scohen commented 1 month ago

we'll see.

scohen commented 1 month ago

btw, I knew that was in our chat history, I didn't know if you wanted that surfaced ;)

dvic commented 1 month ago

we'll see.

Let me know if you need anything else!

scohen commented 1 month ago

Are you 100% sure this is what's causing it? I don't see any block there (or anywhere around the cursor)