TextChangeRange Struct

Describes a region of old text that was replaced, and how long the replacement is.

public readonly struct TextChangeRange : IEquatable<TextChangeRange>

Remarks

Unlike TextChange, a range does not carry the replacement text. It is what an incremental parser needs: enough to map a position in the new text back to the old one.

Implements

Constructors

NameDescription
TextChangeRange(TextSpan, int)

TextChangeRange(TextSpan, int)

TextChangeRange.cs
public TextChangeRange(TextSpan span, int newLength)

Parameters

span TextSpan
newLength int

No documentation is available.

Properties

NameDescription
DeltaGets the number of characters the text grew by, which is negative when it shrank.
NewLengthGets the length the range occupies in the new text.
SpanGets the replaced range, in the old text.

Gets the number of characters the text grew by, which is negative when it shrank.

public int Delta { get; }

Property value

int

Gets the length the range occupies in the new text.

public int NewLength { get; }

Property value

int

Gets the replaced range, in the old text.

public TextSpan Span { get; }

Property value

TextSpan

Methods

NameDescription
Collapse(IEnumerable<TextChangeRange>)Combines changes into the single range that spans all of them.
Equals(TextChangeRange)
Equals(object?)
GetHashCode()
ToString()

Collapse(IEnumerable<TextChangeRange>)

TextChangeRange.cs

Combines changes into the single range that spans all of them.

public static TextChangeRange Collapse(IEnumerable<TextChangeRange> changes)

Parameters

changes IEnumerable<TextChangeRange>
The ranges to combine. They are expected to be ordered by TextChangeRange.Span and not to overlap.

Returns

TextChangeRange A range covering every change, or default when there is none.

Exceptions

ArgumentNullException
changes is null.

Equals overloads

Equals(TextChangeRange)

TextChangeRange.cs
public bool Equals(TextChangeRange other)
Parameters
other TextChangeRange
Returns

bool

No documentation is available.

Equals(object?)

TextChangeRange.cs
public override bool Equals(object? obj)
Parameters
obj object?
Returns

bool

No documentation is available.

GetHashCode()

TextChangeRange.cs
public override int GetHashCode()

Returns

int

No documentation is available.

public override string ToString()

Returns

string

No documentation is available.

Operators

NameDescription
operator ==(TextChangeRange, TextChangeRange)
operator !=(TextChangeRange, TextChangeRange)

operator ==(TextChangeRange, TextChangeRange)

TextChangeRange.cs
public static bool operator ==(TextChangeRange left, TextChangeRange right)

Parameters

left TextChangeRange
right TextChangeRange

Returns

bool

No documentation is available.

operator !=(TextChangeRange, TextChangeRange)

TextChangeRange.cs
public static bool operator !=(TextChangeRange left, TextChangeRange right)

Parameters

left TextChangeRange
right TextChangeRange

Returns

bool

No documentation is available.