VS Code API
    Preparing search index...

    Class Range

    A range represents an ordered pair of two positions. It is guaranteed that start.isBeforeOrEqual(end)

    Range objects are immutable. Use the with, intersection, or union methods to derive new ranges from an existing range.

    Hierarchy (View Summary)

    Index

    Constructors

    • Create a new range from two positions. If start is not before or equal to end, the values will be swapped.

      Parameters

      Returns Range

    • Create a new range from number coordinates. It is a shorter equivalent of using new Range(new Position(startLine, startCharacter), new Position(endLine, endCharacter))

      Parameters

      • startLine: number

        A zero-based line value.

      • startCharacter: number

        A zero-based character value.

      • endLine: number

        A zero-based line value.

      • endCharacter: number

        A zero-based character value.

      Returns Range

    Properties

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

    isEmpty: boolean

    true if start and end are equal.

    isSingleLine: boolean

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

    start: Position

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

    Methods

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

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

      Parameters

      Returns Range | undefined

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

    • Check if other equals this range.

      Parameters

      Returns boolean

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

    • Compute the union of other with this range.

      Parameters

      Returns Range

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

    • Derived a new range from this range.

      Parameters

      • Optionalstart: Position

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

      • Optionalend: 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.