Class Range

Expand description

A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)

Constructors§

§

new Range(
    startLineNumber: number,
    startColumn: number,
    endLineNumber: number,
    endColumn: number,
): Range

Properties§

§readonly endColumn: number

Column on which the range ends in line endLineNumber.

§readonly endLineNumber: number

Line number on which the range ends.

§readonly startColumn: number

Column on which the range starts in line startLineNumber (starts at 1).

§readonly startLineNumber: number

Line number on which the range starts (starts at 1).

Methods§

§

collapseToEnd(): Range

Create a new empty range using this range's end position.

§

collapseToStart(): Range

Create a new empty range using this range's start position.

§

containsPosition(position: IPosition): boolean

Test if position is in this range. If the position is at the edges, will return true.

§

containsRange(range: IRange): boolean

Test if range is in this range. If the range is equal to this range, will return true.

§

delta(lineCount: number): Range

Moves the range by the given amount of lines.

§

equalsRange(other: IRange): boolean

Test if this range equals other.

§

getEndPosition(): Position

Return the end position (which will be after or equal to the start position)

§

getStartPosition(): Position

Return the start position (which will be before or equal to the end position)

§

intersectRanges(range: IRange): Range

A intersection of the two ranges.

§

isEmpty(): boolean

Test if this range is empty.

§

isSingleLine(): boolean

§

plusRange(range: IRange): Range

A reunion of the two ranges. The smallest position will be used as the start point, and the largest one as the end point.

§

setEndPosition(
    endLineNumber: number,
    endColumn: number,
): Range

Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.

§

setStartPosition(
    startLineNumber: number,
    startColumn: number,
): Range

Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.

§

strictContainsRange(range: IRange): boolean

Test if range is strictly in this range. range must start after and end before this range for the result to be true.

§

toJSON(): IRange

§

toString(): string

Transform to a user presentable string representation.

§

areIntersecting(a: IRange, b: IRange): boolean

Test if the two ranges are intersecting. If the ranges are touching it returns true.

§

areIntersectingOrTouching(a: IRange, b: IRange): boolean

Test if the two ranges are touching in any way.

§

areOnlyIntersecting(a: IRange, b: IRange): boolean

Test if the two ranges are intersecting, but not touching at all.

§

collapseToEnd(range: IRange): Range

Create a new empty range using this range's end position.

§

collapseToStart(range: IRange): Range

Create a new empty range using this range's start position.

§

compareRangesUsingEnds(a: IRange, b: IRange): number

A function that compares ranges, useful for sorting ranges It will first compare ranges on the endPosition and then on the startPosition

§

compareRangesUsingStarts(a: IRange, b: IRange): number

A function that compares ranges, useful for sorting ranges It will first compare ranges on the startPosition and then on the endPosition

§

containsPosition(
    range: IRange,
    position: IPosition,
): boolean

Test if position is in range. If the position is at the edges, will return true.

§

containsRange(range: IRange, otherRange: IRange): boolean

Test if otherRange is in range. If the ranges are equal, will return true.

§

equalsRange(a: IRange, b: IRange): boolean

Test if range a equals b.

§

fromPositions(start: IPosition, end?: IPosition): Range

§

getEndPosition(range: IRange): Position

Return the end position (which will be after or equal to the start position)

§

getStartPosition(range: IRange): Position

Return the start position (which will be before or equal to the end position)

§

intersectRanges(a: IRange, b: IRange): Range

A intersection of the two ranges.

§

isEmpty(range: IRange): boolean

Test if range is empty.

§

isIRange(obj: unknown): obj is IRange

Test if obj is an IRange.

§

lift(range: null): null

Create a Range from an IRange.

§

lift(range: IRange): Range

Create a Range from an IRange.

§

lift(range: IRange): Range

Create a Range from an IRange.

§

plusRange(a: IRange, b: IRange): Range

A reunion of the two ranges. The smallest position will be used as the start point, and the largest one as the end point.

§

spansMultipleLines(range: IRange): boolean

Test if the range spans multiple lines.

§

strictContainsRange(
    range: IRange,
    otherRange: IRange,
): boolean

Test if otherRange is strictly in range (must start after, and end before). If the ranges are equal, will return false.