Class: Range
libs/common/types/Range.Range
Hierarchy
Range
Constructors
constructor
• new Range(start
, end
)
Create a new range from two positions. If start
is not
before or equal to end
, the values will be swapped.
Parameters
Name | Type | Description |
---|---|---|
start | Position | A position. |
end | Position | A position. |
Defined in
• new Range(startLine
, startCharacter
, endLine
, endCharacter
)
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
Name | Type | Description |
---|---|---|
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. |
Defined in
Properties
end
• Readonly
end: Position
The end position. It is after or equal to start.
Defined in
start
• Readonly
start: Position
The start position. It is before or equal to end.
Defined in
Accessors
isEmpty
• get
isEmpty(): boolean
true
if start
and end
are equal.
Returns
boolean
Defined in
isSingleLine
• get
isSingleLine(): boolean
true
if start.line
and end.line
are equal.
Returns
boolean
Defined in
Methods
contains
▸ contains(positionOrRange
): boolean
Check if a position or a range is contained in this range.
Parameters
Name | Type | Description |
---|---|---|
positionOrRange | Range | Position | A position or a range. |
Returns
boolean
true
if the position or range is inside or equal
to this range.
Defined in
intersection
▸ intersection(other
): undefined
| Range
Intersect range
with this range and returns a new range or undefined
if the ranges have no overlap.
Parameters
Name | Type | Description |
---|---|---|
other | Range | A range. |
Returns
undefined
| Range
A range of the greater start and smaller end positions. Will return undefined when there is no overlap.
Defined in
libs/common/types/Range.ts:108
isRangeEqual
▸ isRangeEqual(other
): boolean
Check if other
equals this range.
Parameters
Name | Type | Description |
---|---|---|
other | Range | A range. |
Returns
boolean
true
when start and end are equal to
start and end of this range.
Defined in
toSelection
▸ toSelection(isReversed
): Selection
Construct a new selection from this range
Parameters
Name | Type | Description |
---|---|---|
isReversed | boolean | If true active is before anchor |
Returns
A new selection
Defined in
libs/common/types/Range.ts:144
union
▸ union(other
): Range
Compute the union of other
with this range.
Parameters
Name | Type | Description |
---|---|---|
other | Range | A range. |
Returns
A range of smaller start position and the greater end position.
Defined in
libs/common/types/Range.ts:120
with
▸ with(start?
, end?
): Range
Derived a new range from this range.
Parameters
Name | Type | Description |
---|---|---|
start? | Position | A position that should be used as start. The default value is the current start. |
end? | Position | A position that should be used as end. The default value is the current end. |
Returns
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.