Skip to content

Commit

Permalink
make sure weakReference always exist
Browse files Browse the repository at this point in the history
  • Loading branch information
heejaechang committed Feb 15, 2018
1 parent a595eaa commit 97f9a1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/EditorFeatures/Text/Extensions.SnapshotSourceText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ private static ITextImage RecordReverseMapAndGetImage(ITextSnapshot editorSnapsh
if (!s_roslynToEditorSnapshotMap.TryGetValue(textImage, out var weakReference))
{
// put reverse entry that won't hold onto anything
s_roslynToEditorSnapshotMap.GetValue(
weakReference = s_roslynToEditorSnapshotMap.GetValue(
textImage, _ => new WeakReference<ITextSnapshot>(editorSnapshot));
}

#if DEBUG
// forward and reversed map is 1:1 map. as long as snapshot is not null, it can't be
// different
var snapshot = weakReference?.GetTarget();
var snapshot = weakReference.GetTarget();
Contract.ThrowIfFalse(snapshot == null || snapshot == editorSnapshot);
#endif
return textImage;
Expand Down

0 comments on commit 97f9a1c

Please sign in to comment.