Skip to content

completions: avoid invalidating handle_completion_resolve #19841

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

Closed

Conversation

davidbarsky
Copy link
Contributor

(I accidentally pushed this branch to rust-analyzer, not a fork. Sorry about that.)

I noticed that handle_completion_resolve was taking a longer than I expected, especially immediately after a handle_completion on the same completion item. Naively, I'd expect handle_completion_resolve to be largely instant, as we rust-analyzer did most of the required work in handle_completion completion already.

I did some additional digging and realized that—at least, in VS Code—the only differences between the configuration passed to snap.analysis.completions was in the completion_config/forced_resolve_completions_config, specifically, in CompletionFieldsToResolve. The former had resolve_detail/resolve_documentation set to true; the latter set to false.

This set of changes sped up completions on some work-private projects by about ~20% or so.

@Veykril
Copy link
Member

Veykril commented May 22, 2025

I don't understand the logic here. Changing those to true would basically make us not resolve those fields in handle_completion_resolve, meaning we would never populate those fields at all, ever.

That is all fields being set to false is intentional, given in this code path we want to resolve everything.

@davidbarsky
Copy link
Contributor Author

Oh, I understand what my mistake was. For whatever reason, the additional detail/documentation panel that was populated by the completionItem/resolve response was hidden. That meant I didn't see any difference before/after this change except a speedup in completions times.

Still, I think it's strange that resolving a single completion item can take as much time as solving for the initial set of completions. I'll close this PR in the meantime.

@davidbarsky davidbarsky deleted the davidbarsky/avoid-invalidating-completion-items branch May 22, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants