Interface: Target
typings/target.types.Target
Implemented by
Properties
contentRange
• Readonly
contentRange: Range
The range of the content
Defined in
typings/target.types.ts:33
contentSelection
• Readonly
contentSelection: Selection
The content range and is reversed turned into a selection
Defined in
typings/target.types.ts:106
contentText
• Readonly
contentText: string
The text contained in the content range
Defined in
typings/target.types.ts:103
editor
• Readonly
editor: TextEditor
The text editor used for all ranges
Defined in
typings/target.types.ts:27
hasExplicitRange
• Readonly
hasExplicitRange: boolean
If true
, then this target has an explicit range. This attribute is used
by "every"
to determine whether to return all scopes in the iteration
scope or just the ones that overlap with the given target's
contentRange.
Most targets have explicit ranges. As of writing this comment, the only targets that don't are as follows:
- a decorated mark (
"air"
), or - an empty cursor mark (
"this"
with an empty selection), or - an empty
"that"
mark (eg after saying"chuck air"
).
For example, when the user says "change every state air"
, we clear every
statement in the function, but "change every state this"
with a non-empty
selection will only target statements overlapping the cursor.
Defined in
typings/target.types.ts:94
hasExplicitScopeType
• Readonly
hasExplicitScopeType: boolean
If true
, then this target has an explicit scope type, and so should never
be automatically expanded to a containing scope.
Examples of targets that have explicit scopes are ScopeTypeTarget
(eg "funk"
), TokenTarget (eg "token"
), etc.
As of writing this comment, the only target type that doesn't have an explicit scope type is UntypedTarget, which can be constructed by
- using a decorated mark (
"air"
), or - using any cursor mark (
"this"
), or - using a range between decorated marks or cursor marks (eg
"past air"
or"air past bat"
), or - using any
"that"
mark (eg after saying"copy air"
), though this final behaviour will change with #466.
The primary consumer of this attribute is ModifyIfUntypedStage,
which is used in the following situations to automatically expand to a
particular scope type when hasExplicitScopeType
is false
:
- To expand to
"line"
for"pour"
,"clone"
, and"breakpoint"
- To expand to
"token"
for"leading"
and"trailing"
- To expand to nearest containing pair for
"inside"
,"bounds"
, and"rewrap"
- To expand to SnippetVariable.wrapperScopeType for snippet wrapping
- To expand to Snippet.insertionScopeTypes for snippet insertion
For example, when the user says "pour air"
, the
{@link DecoratedSymbolStage} will return an UntypedTarget, which
has hasExplicitScopeType=false
, so "pour"
will expand to the line
containining the air token and insert a newline after it.
Defined in
typings/target.types.ts:75
insertionDelimiter
• Readonly
insertionDelimiter: string
If this selection has a delimiter use it for inserting before or after the target. For example, new line for a line or paragraph and comma for a list or argument
Defined in
typings/target.types.ts:36
isLine
• Readonly
isLine: boolean
If true this target should be treated as a line
Defined in
typings/target.types.ts:39
isNotebookCell
• Readonly
isNotebookCell: boolean
If true this target is a notebook cell
Defined in
typings/target.types.ts:100
isRaw
• Readonly
isRaw: boolean
If true this target is a raw selection and its insertion delimiter should not be used on bring action
Defined in
typings/target.types.ts:97
isReversed
• Readonly
isReversed: boolean
If true active is before anchor
Defined in
typings/target.types.ts:30
thatTarget
• Readonly
thatTarget: Target
Internal target that should be used for the that mark
Defined in
typings/target.types.ts:109
Methods
constructChangeEdit
▸ constructChangeEdit(text
): EditWithRangeUpdater
Constructs change/insertion edit. Adds delimiter before/after if needed
Parameters
Name | Type |
---|---|
text | string |
Returns
Defined in
typings/target.types.ts:129
constructRemovalEdit
▸ constructRemovalEdit(): EditWithRangeUpdater
Constructs removal edit
Returns
Defined in
typings/target.types.ts:131
createContinuousRangeTarget
▸ createContinuousRangeTarget(isReversed
, endTarget
, includeStart
, includeEnd
): Target
Parameters
Name | Type |
---|---|
isReversed | boolean |
endTarget | Target |
includeStart | boolean |
includeEnd | boolean |
Returns
Defined in
typings/target.types.ts:122
getBoundaryStrict
▸ getBoundaryStrict(): Target
[]
Returns
Target
[]
Defined in
typings/target.types.ts:112
getEditNewActionType
▸ getEditNewActionType(): EditNewActionType
Returns
Defined in
typings/target.types.ts:119
getInteriorStrict
▸ getInteriorStrict(): Target
[]
Returns
Target
[]
Defined in
typings/target.types.ts:111
getLeadingDelimiterTarget
▸ getLeadingDelimiterTarget(): undefined
| Target
The range of the delimiter before the content selection
Returns
undefined
| Target
Defined in
typings/target.types.ts:114
getRemovalHighlightRange
▸ getRemovalHighlightRange(): undefined
| Range
Returns
undefined
| Range
Defined in
typings/target.types.ts:118
getRemovalRange
▸ getRemovalRange(): Range
Returns
Defined in
typings/target.types.ts:117
getTrailingDelimiterTarget
▸ getTrailingDelimiterTarget(): undefined
| Target
The range of the delimiter after the content selection
Returns
undefined
| Target
Defined in
typings/target.types.ts:116
isEqual
▸ isEqual(target
): boolean
Parameters
Name | Type |
---|---|
target | Target |
Returns
boolean
Defined in
typings/target.types.ts:132
toPositionTarget
▸ toPositionTarget(position
): Target
Construct a position target with the given position.
Parameters
Name | Type | Description |
---|---|---|
position | Position | The position to use, eg start , end , before , after |
Returns
Defined in
typings/target.types.ts:137
withContentRange
▸ withContentRange(contentRange
): Target
Parameters
Name | Type |
---|---|
contentRange | Range |
Returns
Defined in
typings/target.types.ts:121
withThatTarget
▸ withThatTarget(thatTarget
): Target
Parameters
Name | Type |
---|---|
thatTarget | Target |
Returns
Defined in
typings/target.types.ts:120