Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a text selection in an editor.

Hierarchy

索引

Constructors

constructor

  • new Selection(anchor: Position, active: Position): Selection
  • new Selection(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number): Selection
  • Create a selection from two positions.

    Parameters

    Returns Selection

  • Create a selection from four coordinates.

    Parameters

    • anchorLine: number

      A zero-based line value.

    • anchorCharacter: number

      A zero-based character value.

    • activeLine: number

      A zero-based line value.

    • activeCharacter: number

      A zero-based character value.

    Returns Selection

Properties

Readonly start

start: Position

The start position. It is before or equal to end.

Readonly end

The end position. It is after or equal to start.

isEmpty

isEmpty: boolean

true if start and end are equal.

isSingleLine

isSingleLine: boolean

true if start.line and end.line are equal.

anchor

anchor: Position

The position at which the selection starts. This position might be before or after active.

active

active: Position

The position of the cursor. This position might be before or after anchor.

isReversed

isReversed: boolean

A selection is reversed if active.isBefore(anchor).

Methods

contains

  • Check if a position or a range is contained in this range.

    Parameters

    Returns boolean

    true if the position or range is inside or equal to this range.

isEqual

  • isEqual(other: Range): boolean
  • Check if other equals this range.

    Parameters

    Returns boolean

    true when start and end are equal to start and end of this range.

intersection

  • Intersect range with this range and returns a new range or undefined if the ranges have no overlap.

    Parameters

    Returns undefined | Range

    A range of the greater start and smaller end positions. Will return undefined when there is no overlap.

union

  • Compute the union of other with this range.

    Parameters

    Returns Range

    A range of smaller start position and the greater end position.

with

  • Derived a new range from this range.

    Parameters

    • Optional start: Position

      A position that should be used as start. The default value is the current start.

    • Optional end: Position

      A position that should be used as end. The default value is the current end.

    Returns Range

    A range derived from this range with the given start and end position. If start and end are not different this range will be returned.

  • Derived a new range from this range.

    Parameters

    Returns Range

    A range that reflects the given change. Will return this range if the change is not changing anything.

Generated by TypeDoc