erlang-ls / erlang_ls

The Erlang Language Server
https://erlang-ls.github.io/
Apache License 2.0
626 stars 136 forks source link

Wrong F/A completion in exports #1488

Closed MarkoMin closed 8 months ago

MarkoMin commented 8 months ago

Describe the bug How can I complete functions to f/A instead of f(Args...) when trying to export them? When I want to export few functions in export, the first function is correctly expanded to f/A (if I autocompleted -export), but next ones get wrongly completed to f(Args...). If I don't autocomplete, not even first one works correctly.

To Reproduce Define a module with 2 functions: really_long_name/3 and really_really_long_name/3. Then type "-exp" and autocomplete it to -export([|]). (| is cursor mark :D). Now type "really_lo" and hit autocomplete, you'll get "really_long_name/3". Then type ", really_rea" and autocomplete it, you'll get -export([really_long_name/3, really_really_long_name(Arg1, Arg2, Arg3)]). - which is wrong I believe. Tested on 0.48.0 and 0.50.0 in nvim with coc as lsp plugin, OTP26. If I remember correctly this thing worked on VS-code, but I'm not 100%.

fridayy commented 8 months ago

Hi @MarkoMin!

I've had this issue with earlier versions but with 0.50.0/master I can not reproduce it.

bug-0-(3).webm

I am using nvim v0.9.4 with this set of plugins. Completion provider is nvim-cmp. Maybe this is coc related?

cheers!

plux commented 8 months ago

This can happen if parsing of the -export expression fails. I got an idea how to make it more robust.

plux commented 8 months ago

I've merged a fix for this now. Hopefully it will resolve the issue :)

MarkoMin commented 8 months ago

Works as a charm, great job!

MarkoMin commented 8 months ago

@plux I just noticed the same thing for -export_type. Maybe we should go with function like "is_in_something_that_accepts_FAs" (import, export, export_type, import_type might come soon, etc.

EDIT: my bad, I was on previous version......