[api] Ensure completion symbols returned to API always come from the current snapshot - #64554
Conversation
| return nil, e | ||
| } | ||
| if params.Preferences != nil { | ||
| langSvc.SetUserPreferences(langSvc.UserPreferences().WithCompletionPreferences(*params.Preferences)) |
There was a problem hiding this comment.
If I'm understanding this correctly, we're bringing back preferences sent along with requests? The LSP doesn't work this way so I'm at least moderately concerned we're creating a bad situation for ourselves by having multiple concepts here, but maybe I'm not understanding.
There was a problem hiding this comment.
No, you're understanding. This isn't LSP so I don't see the need for that constraint here in the direct access language service. I can remove it, but it seems useful. The alternative is you have to do a whole extra round trip snapshot clone just to control the preferences for one completions request. The way LSP works makes sense because there's a single persistent state for preferences. I'm not sure it makes as much sense when state forks arbitrarily.
There was a problem hiding this comment.
Removed. We can always add it later if there's a need.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The generated public preference contract rejects a valid organizeImportsCaseFirst: false value, and the symbol-ownership regression test does not exercise the returned symbol handle.
Review effort: Balanced
Findings: 1
Open (3)
Resolved since last review (1)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Ahaha oh no, I got caught doing code analysis with a regular expression. Someone take my compiler engineer license away 😦 |



Fixes #64518 (comment):
This PR adds exactly all of that. Since UserPreferences is now exposed to the API, the second commit generates both the Go and the TS from a schema. Rather than complicate the schema/generation to preserve the Go type exactly as it was, I had the field names and enum constants generated from the actual JSON properties/values that VS Code expects, which accounts for the renaming. I can add more metadata to the schema to undo that, but I kind of prefer the consistency.