Skip to content

Commit

Permalink
Fixed DDRIT failure (dotnet#25551)
Browse files Browse the repository at this point in the history
* made sure we raise workspace changed events even when there is no text change.

this is needed to bring workspace up to date with latest text snapshot after we don't merge 2 text snapshot to 1 source text if content is same.

see this for more detail - dotnet#24849

* added comments on why we need to process all text change events
  • Loading branch information
heejaechang authored and jasonmalinowski committed Mar 19, 2018
1 parent 56502b6 commit 0545c41
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/EditorFeatures/Text/Extensions.TextBufferContainer.cs
Expand Up @@ -100,18 +100,24 @@ public override SourceText CurrentText
private void OnTextContentChanged(object sender, TextContentChangedEventArgs args)
{
var changed = this.EtextChanged;
if (changed != null && args.Changes.Count != 0)
if (changed == null)
{
// this should convert given editor snapshots to roslyn forked snapshots
var oldText = (SnapshotSourceText)args.Before.AsText();
var newText = SnapshotSourceText.From(args.After);
_currentText = newText;

var changes = ImmutableArray.CreateRange(args.Changes.Select(c => new TextChangeRange(new TextSpan(c.OldSpan.Start, c.OldSpan.Length), c.NewLength)));
var eventArgs = new TextChangeEventArgs(oldText, newText, changes);
this.LastEventArgs = eventArgs;
changed(sender, eventArgs);
return;
}

// we should process all changes even though there is no text changes
// otherwise, Workspace.CurrentSolution won't move forward to latest ITextSnapshot

// this should convert given editor snapshots to roslyn forked snapshots
var oldText = (SnapshotSourceText)args.Before.AsText();
var newText = SnapshotSourceText.From(args.After);
_currentText = newText;

var changes = ImmutableArray.CreateRange(args.Changes.Select(c => new TextChangeRange(new TextSpan(c.OldSpan.Start, c.OldSpan.Length), c.NewLength)));
var eventArgs = new TextChangeEventArgs(oldText, newText, changes);

this.LastEventArgs = eventArgs;
changed(sender, eventArgs);
}

// These are the event args that were last sent from this text container when the text
Expand Down

0 comments on commit 0545c41

Please sign in to comment.