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

Ensure we don't send duplicate changes when unique filenames aren't used #9141

Merged
merged 11 commits into from
Aug 21, 2023

Conversation

davidwengier
Copy link
Member

Second attempt at fixing various issues: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1867769, https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1868418, https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1868479, #9131, #9125 and #9060

Also fixes #9138

Turns out my previous fix, which I pulled out of my other PR, didn't quite go far enough and specifically failed for documents that were restored to their open state in VS Code/VS and for documents that were seen to be in the "Misc Files" project before appearing in a real project.

@davidwengier davidwengier requested a review from a team as a code owner August 21, 2023 07:32
// For example, when a document moves from the Misc Project to a real project, we will update it here, and each version would
// have a different project key. On the receiving end however, there is only one file path, therefore one version of the contents,
// so we must ensure we only have a single document to compute diffs from, or things get out of sync.
// if (!_languageServerFeatureOptions.IncludeProjectKeyInGeneratedFilePath)
Copy link
Member Author

Choose a reason for hiding this comment

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

This line of code will be commented out in my other open PR, the feature flag doesn't exist in main yet.

@@ -59,7 +59,7 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(SemanticTokensRangeParam
var semanticTokens = await semanticTokensInfoService.GetSemanticTokensAsync(request.TextDocument, request.Range, documentContext, _razorSemanticTokensLegend.AssumeNotNull(), correlationId, cancellationToken).ConfigureAwait(false);
var amount = semanticTokens is null ? "no" : (semanticTokens.Data.Length / 5).ToString(Thread.CurrentThread.CurrentCulture);

requestContext.Logger.LogInformation("Returned {amount} semantic tokens for range {request.Range} in {request.TextDocument.Uri}.", amount, request.Range, request.TextDocument.Uri);
requestContext.Logger.LogInformation("Returned {amount} semantic tokens for range ({startLine},{startChar})-({endLine}-{endChar})} in {request.TextDocument.Uri}.", amount, request.Range.Start.Line, request.Range.Start.Character, request.Range.End.Line, request.Range.End.Character, request.TextDocument.Uri);
Copy link
Member Author

@davidwengier davidwengier Aug 21, 2023

Choose a reason for hiding this comment

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

Just noticed this in the log. It used to just [Info - 2:31:15 PM] Returned 50 semantic tokens for range Microsoft.VisualStudio.LanguageServer.Protocol.Range in file:///Users/vs/worker/WebApplication1/Pages/Index.cshtml.

@@ -155,4 +155,78 @@ public async Task OpenExistingProject()
var actualProjectFileName = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ProjectFile, ControlledHangMitigatingCancellationToken);
Assert.Equal(expectedProjectFileName, actualProjectFileName);
}

[IdeFact(MaxAttempts = 1)]
public async Task OpenExistingProject_WithReopenedFile()
Copy link
Member Author

Choose a reason for hiding this comment

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

I've added this test, and the one below, just in case, but it turns out they don't fail even without the fixes in this PR, because of other issues. Have started a Teams thread about it.

@davidwengier davidwengier merged commit 7530bea into dotnet:main Aug 21, 2023
@ghost ghost added this to the Next milestone Aug 21, 2023
@davidwengier davidwengier deleted the FixGeneratedDocuments branch August 21, 2023 22:32
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
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.

Request textDocument/formatting failed.
3 participants