private void OnTextContentChanged(object?sender, TextContentChangedEventArgs args) { var changed = this.EtextChanged; if (changed == null) { 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(_textBufferCloneService, 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); }
private TextBufferContainer(ITextBuffer editorBuffer) { Contract.ThrowIfNull(editorBuffer); _weakEditorBuffer = new WeakReference <ITextBuffer>(editorBuffer); _currentText = SnapshotSourceText.From(editorBuffer.CurrentSnapshot, this); }
public static SourceText AsText(this ITextSnapshot textSnapshot) { textSnapshot.TextBuffer.Properties.TryGetProperty <ITextBufferCloneService>( typeof(ITextBufferCloneService), out var textBufferCloneServiceOpt ); return(SnapshotSourceText.From(textBufferCloneServiceOpt, textSnapshot)); }
private TextBufferContainer(ITextBuffer editorBuffer) { Contract.ThrowIfNull(editorBuffer); _weakEditorBuffer = new WeakReference <ITextBuffer>(editorBuffer); editorBuffer.Properties.TryGetProperty(typeof(ITextBufferCloneService), out _textBufferCloneServiceOpt); _currentText = SnapshotSourceText.From(_textBufferCloneServiceOpt, editorBuffer.CurrentSnapshot, this); }
private void OnTextContentChanged(object sender, TextContentChangedEventArgs args) { var changed = this.EtextChanged; if (changed != null && args.Changes.Count != 0) { // 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); } }
public static SourceText AsText(this ITextSnapshot textSnapshot) => SnapshotSourceText.From(textSnapshot);
public static SourceText AsText(this ITextSnapshot textSnapshot) { return(SnapshotSourceText.From(textSnapshot)); }
public static SourceText AsText(this ITextSnapshot textSnapshot) => SnapshotSourceText.From(textBufferCloneServiceOpt: null, textSnapshot);