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

Recalculate if LSP inlay hint cache miss #75709

Merged
merged 4 commits into from
Nov 4, 2024
Merged

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Nov 2, 2024

Resolves one of the failures listed in https://prism.vsdata.io/failure/?query=%20sev!%3DDiagnostic%20p%3Dcsdevkit&eventType=fault&failureType=hits&failureHash=32e9e891-7092-eff4-347c-8767c8db6ba0

Not too hard to repro in VSCode - having a few editors opened side by side will cause cache misses when resolving inlay hints between the different editors. Instead of throwing we can easily recalculate.

@dibarbet dibarbet requested a review from a team as a code owner November 2, 2024 02:36
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 2, 2024
{
ErrorCode = LspErrorCodes.ContentModified
};
}

var taggedText = await inlineHintToResolve.GetDescriptionAsync(document, cancellationToken).ConfigureAwait(false);
var inlineHintToResolve = GetCacheEntry(resolveData, inlayHintCache);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to audit any other cases?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're talking about other caches in different handlers, I believe we're good. We only also use a cache in completion, which doesn't have this same issue - switching editor focus will always dismiss the previous list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switching editor focus will always dismiss the previous list

Perhaps. Though that seemsl ike a host-specific behavior. Would we have an issue if the host chnaged and decided to not do that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: i'm not saying we need to do anything here. Just wanted to have this occupy a few brain cycles thinking about this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the client ever allowed multiple completion sessions at once, then completion will function, but at a slightly degraded experience - the items could be committed, but would not have documentation. Additionally items with additional text edits (for example unimported types), or complex edits (for example override completion) would only apply the word edit, and not the additional ones.

It may be technically possible to recalculate in completion - but that would slow down the resolve request a fair amount. IMHO if we want to support the multiple lists at once scenario I'd much prefer adding something to the spec similar to microsoft/language-server-protocol#1802 (comment) that allows the client to tell us which completion items to hold onto (and for how long).


var inlineHintService = document.GetRequiredLanguageService<IInlineHintsService>();
var hints = await inlineHintService.GetInlineHintsAsync(document, textSpan, options, resolveData.DisplayAllOverride, cancellationToken).ConfigureAwait(false);
var hints = await InlayHintHandler.CalculateInlayHintsAsync(document, resolveData.Range, options, resolveData.DisplayAllOverride, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you :)

@dibarbet dibarbet merged commit 985a2a3 into dotnet:main Nov 4, 2024
25 checks passed
@dibarbet dibarbet deleted the inlay_hint_nfw branch November 4, 2024 21:01
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 4, 2024
@jjonescz jjonescz modified the milestones: Next, 17.13 P2 Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants