Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete at end of line with whitespace #3625

Closed
adampauls opened this issue Feb 10, 2022 · 4 comments · Fixed by #3704
Closed

Autocomplete at end of line with whitespace #3625

adampauls opened this issue Feb 10, 2022 · 4 comments · Fixed by #3704
Labels
improvement Not a bug or a feature, but something general we can improve Scala 3 Generic ticket relating to Scala 3

Comments

@adampauls
Copy link

Describe the bug

With this prefix:

object Test:
  case class Widget(name: String, other: Int)
  val otxxx: Int = 1
  Widget(name = "foo", 

autocomplete will (correctly) suggest both otxxx and other if either (a) the cursor is immediately after the comma, or (b) there is another line (like val x = 5) after the Widget line.

I think this might be a bug in the underlying Scala parser, but I am not sure.

Expected behavior

Autocomplete should behave the same regardless of whitespace in this case.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.12.0

Extra context or search terms

No response

@tgodzik
Copy link
Contributor

tgodzik commented Feb 10, 2022

Thanks for reporting! Suprisingly, if you start writing o it will also suggest the correct completions. I think this is one of the cases that we might need to add the artificial CURSOR name so that the parser doesn't fail. It's something we haven't yet ported from Scala 2.

@tgodzik tgodzik added improvement Not a bug or a feature, but something general we can improve Scala 3 Generic ticket relating to Scala 3 labels Feb 10, 2022
@adampauls
Copy link
Author

Hmm, actually, now I'm confused. Look at what I believe are dotty's completion unit tests, there are no unit tests for filling in arguments to an Apply, i.e. nothing like foo(${m1}. Does the functionality for filling in argument names and values by type live only in Metals? If so, can I have a good pointer? If not, do you know where it dotty it is tested?

@adampauls
Copy link
Author

Ah, I found this, so it seems that the Scala compiler only provides some of the completions functionality.

@tgodzik
Copy link
Contributor

tgodzik commented Feb 11, 2022

We do a number of custom completions that are built upon the information from the Dotty presentation compiler. We try to port some of the improvements to the compiler itself, but since that can be used by a number of different tools we need to be careful what we include upstream.

tgodzik added a commit to tgodzik/metals that referenced this issue Mar 11, 2022
The issue has been fixed in the compiler.

Fixes scalameta#3625
tgodzik added a commit that referenced this issue Mar 12, 2022
Duhemm pushed a commit to Duhemm/metals that referenced this issue Mar 23, 2022
The issue has been fixed in the compiler.

Fixes scalameta#3625
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Not a bug or a feature, but something general we can improve Scala 3 Generic ticket relating to Scala 3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants