-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix completions from backticked identifiers #10986
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
Conversation
Scala 3 handles this case correctly. I spent some time looking at the Scala 3 version of this code and realized from there that all of this reverse engineering of where the identifier starts is unnecessary - I think we can just use Scala 3 code - almost all of which is actually about cases Scala 2 doesn't worry about. The case for |
Thanks! It doesn't seem to work in the REPL, so there's something else in the way there. It's fine with me if you want to leave that aside. But I wonder if returning Did you check if completing It would also be nice if |
2.13 only and needs scala/scala#10986. 3.x version should not need upstream changes - completion API seems to already work around backticks.
I think those might be due to pre-existing gaps. I'll double check though. Especially the first point surprises me a bit. I'd expect that if you have the closing backtick, the completion should work...
I think so, but I'll check. I've been using this while exploring scalameta/metals-feature-requests#418 (see the screenshots there - the behavior at least through metals keeps the backticks in place).
That won't work yet - we'd need to back port this logic. This matters less for Metals since we can instead configure editors to auto-close backticks (plus that's more robust if you are in the middle of a line - the rest of your line doesn't get parsed into the backticked ident) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LMK when you're done. We can go ahead as it currently is - modulo my question below.
Alright, I did a loop here and I don't think there's anything further I want to investigate for now. LMK if that's OK. I unsuccessfully took a stab at getting the REPL to support correctly adding backticks (scala/bug#6919) just in case I could use that to determine definitively the "right" I've since made the LSP half of this change for Scala 3.6 (scala/scala3#22555). My plan is to get this PR merged and then merge scalameta/metals#7204 to get roughly the same behavior in 2.13.x. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can go ahead with this. Just a small suggestion.
The code detecting the completion prefix of the identifier before the cursor was not accounting for that identifier potentially being backticked. This manifests both in the REPL where TAB completing inside backticks doesn't work and (what I care about more) in the presentation compiler `completionsAt` API.
f2c96ff
to
54d5f37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@lrytz When do you expect Scala 2.13.17 to be released? Looking at the last several releases in the 2.13.x, it seems like they are roughly every 4-6 month, so that would but 2.13.17 around June, right? |
@harpocrates in short, we don't know for sure yet (see https://contributors.scala-lang.org/t/scala-2-13-17-release-planning/6994) but yes, 4–6 months is a good guess. we don't currently have a reason to do it faster |
It is possible to work around it in Metals by switching to a method, that will match on the changed cases and use completionsAt otherwise. |
The code detecting the completion prefix of the identifier before the cursor was not accounting for that identifier potentially being backticked.
This manifests both in the REPL where TAB completing inside backticks doesn't work and (what I care about more) in the presentation compiler
completionsAt
API.