Struct TextPosition
A position in the text of a document as the tools of an assistant say it: a 1-based line and a 1-based column, the first character of a document
being at 1:1.
public readonly record struct TextPosition : IEquatable<TextPosition>
- Implements
- Inherited Members
Remarks
A column counts UTF-16 code units, as LSP does. The tools read and write positions 1-based, as a listing numbers its lines, where every LSP message is 0-based (SourcePosition).
Constructors
TextPosition(int, int)
A position in the text of a document as the tools of an assistant say it: a 1-based line and a 1-based column, the first character of a document
being at 1:1.
public TextPosition(int Line, int Column)
Parameters
Remarks
A column counts UTF-16 code units, as LSP does. The tools read and write positions 1-based, as a listing numbers its lines, where every LSP message is 0-based (SourcePosition).
Properties
Column
The column, from 1.
public int Column { get; init; }
Property Value
Line
The line, from 1.
public int Line { get; init; }
Property Value
Methods
Of(SourcePosition)
The position a 0-based position is.
public static TextPosition Of(SourcePosition position)
Parameters
positionSourcePositionThe 0-based position.
Returns
- TextPosition
The same position, 1-based.
ToSourcePosition()
The 0-based position this position is.
public SourcePosition ToSourcePosition()
Returns
- SourcePosition
The same position, 0-based.
Exceptions
- ArgumentOutOfRangeException
The line or the column is less than 1.
ToString()
The position as a listing writes it: 12:5.
public override string ToString()
Returns
- string
The line and the column, with a colon between them.