Class Selection

Expand description

A selection in the editor. The selection is a range that has an orientation.

Constructors§

§

new Selection(
    selectionStartLineNumber: number,
    selectionStartColumn: number,
    positionLineNumber: number,
    positionColumn: number,
): Selection

Properties§

§readonly endColumn: number

Column on which the range ends in line endLineNumber.

§readonly endLineNumber: number

Line number on which the range ends.

§readonly positionColumn: number

The column on positionLineNumber where the selection has ended.

§readonly positionLineNumber: number

The line number on which the selection has ended.

§readonly selectionStartColumn: number

The column on selectionStartLineNumber where the selection has started.

§readonly selectionStartLineNumber: number

The line number on which the selection has started.

§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.

§

equalsSelection(other: ISelection): boolean

Test if equals other selection.

§

getDirection(): SelectionDirection

Get directions (LTR or RTL).

§

getEndPosition(): Position

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

§

getPosition(): Position

Get the position at positionLineNumber and positionColumn.

§

getSelectionStart(): Position

Get the position at the start of the selection.

§

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,
): Selection

Create a new selection with a different positionLineNumber and positionColumn.

§

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

Create a new selection with a different selectionStartLineNumber and selectionStartColumn.

§

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 human-readable 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.

§

createWithDirection(
    startLineNumber: number,
    startColumn: number,
    endLineNumber: number,
    endColumn: number,
    direction: SelectionDirection,
): Selection

Create with a direction.

§

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

Test if range a equals b.

§

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

Create a Selection from one or two positions

§

fromRange(
    range: Range,
    direction: SelectionDirection,
): Selection

Creates a Selection from a range, given a direction.

§

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.

§

isISelection(obj: unknown): obj is ISelection

Test if obj is an ISelection.

§

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.

§

liftSelection(sel: ISelection): Selection

Create a Selection from an ISelection.

§

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.

§

selectionsArrEqual(
    a: ISelection[],
    b: ISelection[],
): boolean

a equals b.

§

selectionsEqual(a: ISelection, b: ISelection): boolean

Test if the two selections are equal.

§

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.