共用方式為


TextPosition Struct

Definition

An immutable text position in a particular ITextDocumentSnapshot version.

public readonly struct TextPosition : IComparable<Microsoft.VisualStudio.Extensibility.Editor.TextPosition>
type TextPosition = struct
Public Structure TextPosition
Implements IComparable(Of TextPosition)
Inheritance
TextPosition
Implements

Remarks

VersionedTextDocumentPositionContract is one of three closely related concepts: - TextPosition: Thick object representing a range of text in a ITextDocumentSnapshot. This type should be used in all code within the same process. - VersionedTextDocumentPositionContract: A serializable representation of TextPosition that can be sent between processes over RPC. This type should be used in most RPC contracts between processes. - TextPositionContract: A serialiable representation of TextPosition that can be sent between processes over RPC. As opposed to VersionedTextDocumentPositionContract, it omits the Uri and document version, making for a smaller serializable representation. This type should be used in RPC contracts that contain lots of position equivalents that need to reduce their payload size for performance. These RPC contracts will need to pass the document Uri and version for the range to be rehydrated into TextRange by IEditorHostService.

Constructors

TextPosition(ITextDocumentSnapshot, Int32)

Initializes a new instance of a TextPosition with respect to a particular ITextDocumentSnapshot version.

Properties

Document

Gets the ITextDocumentSnapshot to which this snapshot position refers.

Offset

Gets the position of the position as a numeric offset from the start of the document.

RpcContract

Converts this thick object into a serializable representation for use in an RPC call.

Methods

Add(Int32)

Creates a new snapshot position at the specified offset from this position.

CompareTo(TextPosition)

Determines whether this snapshot is the same as a second snapshot position.

Difference(TextPosition)

Computes the offset between this snapshot position and another snapshot position.

Equals(Object)

Determines whether this snapshot position is the same as a second snapshot position.

GetChar()

Gets the character at the position of this snapshot position.

GetContainingLine()

The ITextDocumentSnapshotLine containing this snapshot position.

GetHashCode()

Serves as a hash function for this type.

Subtract(Int32)

Creates a new snapshot position at the specified negative offset from this position.

TranslateTo(ITextDocumentSnapshot, TextPositionTrackingMode)

Translates this TextPosition to an older or newer ITextDocumentSnapshot version.

Operators

Addition(TextPosition, Int32)

Increments the position of a snapshot position.

Equality(TextPosition, TextPosition)

Determines whether this snapshot position is the same as a second snapshot position.

GreaterThan(TextPosition, TextPosition)

Determines whether the position of one snapshot position is greater than the position of a second snapshot position.

Implicit(TextPosition to Int32)

Implicitly converts the snapshot position to an integer equal to the position of the snapshot position in the snapshot.

Implicit(TextPosition to VersionedTextDocumentPositionContract)

Implicitly converts the TextPosition to VersionedTextDocumentPositionContract.

Inequality(TextPosition, TextPosition)

Determines whether this snapshot position is different from a second snapshot position.

LessThan(TextPosition, TextPosition)

Determine if the position of the left position is less than the position of the right position.

Subtraction(TextPosition, Int32)

Decrements the position of a snapshot position.

Subtraction(TextPosition, TextPosition)

Computes the offset between two TextPosition objects.

Applies to