erlang_ls icon indicating copy to clipboard operation
erlang_ls copied to clipboard

using the add'_' to Variable causes duplication of the clause

Open TheGeorge opened this issue 3 years ago • 6 comments

Describe the bug

some(Variable) -> ok.

and using the code action on Variable resutls in

some(_Variable) -> ok.
some(Variable) -> ok.

instead of just

some(_Variable) -> ok.

Context

  • erlang_ls version (tag/sha): 0.18.0
  • Editor used: VSCode

TheGeorge avatar Sep 10 '21 11:09 TheGeorge

@TheGeorge I cannot reproduce this with the latest HEAD. Tried both Emacs and VS Code. Do you mind adding a test case showing this issue? Maybe it's a corner case which only gets triggered under certain conditions?

robertoaloi avatar Sep 20 '21 08:09 robertoaloi

Ping @TheGeorge

robertoaloi avatar Oct 04 '21 07:10 robertoaloi

I totally missed this, let me check if this is still broken

TheGeorge avatar Nov 03 '21 17:11 TheGeorge

I totally missed this, let me check if this is still broken

It was broken as of yesterday.

sopotc avatar Nov 04 '21 10:11 sopotc

@robertoaloi This reproduces the error for me

-module(unused).

-export[hello/1].

hello() ->
  Wow = 8,
  "Hello World".

I'm using latest HEAD and VS Code

From what I can tell the issue might be related to the range, in my case the start and end line received by els_code_action_provider:handle_request are the same (5) so according to a note in replace_lines_action that would add the line instead of replacing it.

I tested modifying the generated command to have EndLine+1 and it solved the issue, but wondering why you couldn't replicate it and if there is something else going on

AminArria avatar Feb 08 '22 17:02 AminArria

Can confirm in Sublime Text 4 (4127) and Sublime LSP v1.15.0.

eproxus avatar Feb 11 '22 15:02 eproxus

Fixed

plux avatar Dec 21 '23 21:12 plux