Skip to content

Commit

Permalink
made sure we raise workspace changed events even when there is no tex…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
heejaechang committed Mar 17, 2018
1 parent 2e5e614 commit f297127
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/EditorFeatures/Text/Extensions.TextBufferContainer.cs
Expand Up @@ -100,18 +100,21 @@ 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;
}

// 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 f297127

Please sign in to comment.