IProjectionBuffer.ReplaceSpans Method

Replaces a sequence of source spans with a new list of ITrackingSpan objects and/or literal strings.

Namespace:  Microsoft.VisualStudio.Text.Projection
Assembly:  Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)

IProjectionSnapshot ReplaceSpans(
	int position,
	int spansToReplace,
	IList<Object> spansToInsert,
	EditOptions options,
	Object editTag


Type: Int32

The position at which to begin replacing spans.

Type: Int32

The number of spans to replace.

Type: IList<Object>

The new spans to insert.

Type: Microsoft.VisualStudio.Text.EditOptions

Options to apply to the span edit.

Type: Object

An object that will be associated with this edit transaction.


spansToInsert is null or a span in the list are null.


position is less than zero or greater than the number of spans.


spansToReplace is less than zero or position + spansToReplace is greater than the number of spans.


An element of spansToInsert is neither an ITrackingSpan nor a string.


A span in spansToInsert would cause a duplicated projection.


A tracking span in spansToInsert is EdgeInclusive and does not cover its entire buffer, or is EdgePositive and does not abut the end of its buffer, or is EdgeNegative and does not abut the beginning of its buffer.

(These checks are not performed if the projection buffer was created with the PermissiveEdgeInclusiveSourceSpans.)


Adding a text buffer containing one of the spansToInsert would create a cycle among a set of projection buffers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft