private void PerformInitialBasicPasteInRawString( out SourceText textAfterBasicPaste, out ImmutableArray <TextSpan> contentSpansAfterBasicPaste) { var trivialContentEdit = GetContentEditForRawString(insertInterpolations: false, dollarSignCount: -1); // We want to map spans forward (which requires tracking spans), but we don't want to modify the original // text buffer. So clone the text buffer to a new one where we can then make the change without touching // the original. var clonedBuffer = _textBufferFactoryService.CreateTextBuffer( new SnapshotSpan(SnapshotBeforePaste, 0, SnapshotBeforePaste.Length), SnapshotBeforePaste.ContentType); var snapshotBeforeTrivialEdit = clonedBuffer.CurrentSnapshot; var edit = clonedBuffer.CreateEdit(); edit.Replace(_selectionSpanBeforePaste.ToSpan(), trivialContentEdit.NewText); var snapshotAfterTrivialEdit = edit.Apply(); textAfterBasicPaste = snapshotAfterTrivialEdit.AsText(); contentSpansAfterBasicPaste = StringExpressionBeforePasteInfo.ContentSpans.SelectAsArray( ts => MapSpan(ts, snapshotBeforeTrivialEdit, snapshotAfterTrivialEdit)); }
public ITextBuffer Clone(SnapshotSpan span) { return(_textBufferFactoryService.CreateTextBuffer(span, _unknownContentType)); }