diff --git a/src/Compilers/Core/Portable/Text/ChangedText.cs b/src/Compilers/Core/Portable/Text/ChangedText.cs index 2b0f83c2d639b033785dba0924b8fb65b1c293c4..81d6fe49e8f2bfbd34503e26ba13be83da4c2c31 100644 --- a/src/Compilers/Core/Portable/Text/ChangedText.cs +++ b/src/Compilers/Core/Portable/Text/ChangedText.cs @@ -21,6 +21,7 @@ public ChangedText(SourceText oldText, SourceText newText, ImmutableArray changes) { // compute changes against newText to avoid capturing strong references to this ChangedText instance. - // note: _newText is never a ChangedText, so if WithChanges is a no-op the result will not be a ChangedText + // _newText will only ever be one of CompositeText, SubText, StringText or LargeText, so calling WithChanges on it + // will either produce a ChangeText instance or the original instance in case of a empty change. var changed = _newText.WithChanges(changes) as ChangedText; if (changed != null) { @@ -91,6 +93,7 @@ public override SourceText WithChanges(IEnumerable changes) } else { + // change was empty, so just return this same instance return this; } }