Skip to content

Commit

Permalink
Merge pull request #74905 from Cosifne/dev/shech/RenameDismissedProblem
Browse files Browse the repository at this point in the history
Double check document changes when dismiss rename
  • Loading branch information
Cosifne authored Aug 27, 2024
2 parents ce07de2 + 649a76e commit d4adac6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/EditorFeatures/Core/InlineRename/InlineRenameSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,19 @@ private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs args)
{
if (args.Kind != WorkspaceChangeKind.DocumentChanged)
{
Logger.Log(FunctionId.Rename_InlineSession_Cancel_NonDocumentChangedWorkspaceChange, KeyValueLogMessage.Create(m =>
// Make sure only call Cancel() when there is real document changes.
// Sometimes, WorkspaceChangeKind.SolutionChanged might be triggered because of SourceGeneratorVersion get updated.
// We don't want to cancel rename when there is no changed documents.
var changedDocuments = args.NewSolution.GetChangedDocuments(args.OldSolution);
if (changedDocuments.Any())
{
m["Kind"] = Enum.GetName(typeof(WorkspaceChangeKind), args.Kind);
}));
Logger.Log(FunctionId.Rename_InlineSession_Cancel_NonDocumentChangedWorkspaceChange, KeyValueLogMessage.Create(m =>
{
m["Kind"] = Enum.GetName(typeof(WorkspaceChangeKind), args.Kind);
}));

Cancel();
Cancel();
}
}
}

Expand Down

0 comments on commit d4adac6

Please sign in to comment.