public async Task <SourceText> GetFinalMergedTextAsync(CancellationToken cancellationToken) { // WithChanges requires a ordered list of TextChanges without any overlap. var changesToApply = _totalChangesIntervalTree.Distinct().OrderBy(tc => tc.Span.Start); var oldText = await _oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var newText = oldText.WithChanges(changesToApply); return(newText); }