Skip to content

Commit

Permalink
Merge pull request #34195 from jasonmalinowski/fix-race-in-getopendoc…
Browse files Browse the repository at this point in the history
…umentincurrentcontextwithchanges

Fix race in GetOpenDocumentInCurrentContextWithChanges
  • Loading branch information
jasonmalinowski authored Mar 19, 2019
2 parents 2b21099 + 6bfb43d commit 559630b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Workspaces/Core/Portable/Workspace/TextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ public static Document GetOpenDocumentInCurrentContextWithChanges(this SourceTex
{
if (Workspace.TryGetWorkspace(text.Container, out var workspace))
{
var solution = workspace.CurrentSolution;
var id = workspace.GetDocumentIdInCurrentContext(text.Container);
if (id == null || !workspace.CurrentSolution.ContainsDocument(id))
if (id == null || !solution.ContainsDocument(id))
{
return null;
}

var sol = workspace.CurrentSolution.WithDocumentText(id, text, PreservationMode.PreserveIdentity);
return sol.GetDocument(id);
return solution.WithDocumentText(id, text, PreservationMode.PreserveIdentity)
.GetDocument(id);
}

return null;
Expand Down

0 comments on commit 559630b

Please sign in to comment.