diff --git a/src/core/inferFullTargets.ts b/src/core/inferFullTargets.ts index 3a113f172a..2a7906c608 100644 --- a/src/core/inferFullTargets.ts +++ b/src/core/inferFullTargets.ts @@ -75,6 +75,7 @@ function inferRangeTarget( type: "range", excludeAnchor: target.excludeStart ?? false, excludeActive: target.excludeEnd ?? false, + rangeType: target.rangeType ?? "continuous", anchor: inferPrimitiveTarget( target.start, previousTargets, diff --git a/src/processTargets/index.ts b/src/processTargets/index.ts index 14c9b85292..cb7a89dffe 100644 --- a/src/processTargets/index.ts +++ b/src/processTargets/index.ts @@ -82,85 +82,98 @@ function processRangeTarget( activeSelection.start ); - // Selection type column is actually a special form of ranged target - if ( - anchorTarget.selectionType === "column" || - activeTarget.selectionType === "column" - ) { - return processColumnTarget( - target, - anchorTarget, - activeTarget, - isForward - ); + switch (target.rangeType) { + case "continuous": + return processContinuousRangeTarget( + target, + anchorTarget, + activeTarget, + isForward + ); + case "vertical": + return processVerticalRangeTarget( + target, + anchorTarget, + activeTarget, + isForward + ); } + } + ); +} - const anchor = targetToRangeLimitPosition( - anchorTarget, - isForward, - !target.excludeAnchor - ); - const active = targetToRangeLimitPosition( - activeTarget, - !isForward, - !target.excludeActive - ); +function processContinuousRangeTarget( + target: RangeTarget, + anchorTarget: TypedSelection, + activeTarget: TypedSelection, + isForward: boolean +): TypedSelection[] { + const anchor = targetToRangeLimitPosition( + anchorTarget, + isForward, + !target.excludeAnchor + ); + const active = targetToRangeLimitPosition( + activeTarget, + !isForward, + !target.excludeActive + ); - const outerAnchor = target.excludeAnchor - ? null - : isForward - ? anchorTarget.selectionContext.outerSelection?.start - : anchorTarget.selectionContext.outerSelection?.end; - const outerActive = target.excludeActive - ? null - : isForward - ? activeTarget.selectionContext.outerSelection?.end - : activeTarget.selectionContext.outerSelection?.start; - const outerSelection = - outerAnchor != null || outerActive != null - ? new Selection(outerAnchor ?? anchor, outerActive ?? active) - : null; + const outerAnchor = target.excludeAnchor + ? null + : isForward + ? anchorTarget.selectionContext.outerSelection?.start + : anchorTarget.selectionContext.outerSelection?.end; + const outerActive = target.excludeActive + ? null + : isForward + ? activeTarget.selectionContext.outerSelection?.end + : activeTarget.selectionContext.outerSelection?.start; + const outerSelection = + outerAnchor != null || outerActive != null + ? new Selection(outerAnchor ?? anchor, outerActive ?? active) + : null; - const startSelectionContext = target.excludeAnchor - ? null - : anchorTarget.selectionContext; - const endSelectionContext = target.excludeActive - ? null - : activeTarget.selectionContext; - const leadingDelimiterRange = isForward - ? startSelectionContext?.leadingDelimiterRange - : endSelectionContext?.leadingDelimiterRange; - const trailingDelimiterRange = isForward - ? endSelectionContext?.trailingDelimiterRange - : startSelectionContext?.trailingDelimiterRange; + const startSelectionContext = target.excludeAnchor + ? null + : anchorTarget.selectionContext; + const endSelectionContext = target.excludeActive + ? null + : activeTarget.selectionContext; + const leadingDelimiterRange = isForward + ? startSelectionContext?.leadingDelimiterRange + : endSelectionContext?.leadingDelimiterRange; + const trailingDelimiterRange = isForward + ? endSelectionContext?.trailingDelimiterRange + : startSelectionContext?.trailingDelimiterRange; - return { - selection: { - selection: new Selection(anchor, active), - editor: anchorTarget.selection.editor, - }, - selectionType: anchorTarget.selectionType, - selectionContext: { - containingListDelimiter: - anchorTarget.selectionContext.containingListDelimiter, - isInDelimitedList: anchorTarget.selectionContext.isInDelimitedList, - leadingDelimiterRange, - trailingDelimiterRange, - outerSelection, - }, - insideOutsideType: anchorTarget.insideOutsideType, - position: "contents", - }; - } - ); + return [ + { + selection: { + selection: new Selection(anchor, active), + editor: anchorTarget.selection.editor, + }, + selectionType: anchorTarget.selectionType, + selectionContext: { + containingListDelimiter: + anchorTarget.selectionContext.containingListDelimiter, + isInDelimitedList: anchorTarget.selectionContext.isInDelimitedList, + leadingDelimiterRange, + trailingDelimiterRange, + outerSelection, + }, + insideOutsideType: anchorTarget.insideOutsideType, + position: "contents", + }, + ]; } -function processColumnTarget( +function processVerticalRangeTarget( target: RangeTarget, anchorTarget: TypedSelection, activeTarget: TypedSelection, isForward: boolean -) { +): TypedSelection[] { const anchorLine = targetToLineLimitPosition( anchorTarget, isForward, @@ -186,7 +199,7 @@ function processColumnTarget( ), editor: anchorTarget.selection.editor, }, - selectionType: "column", + selectionType: anchorTarget.selectionType, selectionContext: { containingListDelimiter: anchorTarget.selectionContext.containingListDelimiter, diff --git a/src/processTargets/processSelectionType.ts b/src/processTargets/processSelectionType.ts index a58e394ae7..cd6a714353 100644 --- a/src/processTargets/processSelectionType.ts +++ b/src/processTargets/processSelectionType.ts @@ -24,7 +24,6 @@ export default function ( ): TypedSelection { switch (target.selectionType) { case "token": - case "column": return processToken(target, selection, selectionContext); case "notebookCell": return processNotebookCell(target, selection, selectionContext); diff --git a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToAfterColumnBatPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToAfterBatVerticalPastFine.yml similarity index 73% rename from src/test/suite/fixtures/recorded/selectionTypes/bringAirToAfterColumnBatPastFine.yml rename to src/test/suite/fixtures/recorded/compoundTargets/bringAirToAfterBatVerticalPastFine.yml index e8cfb841f3..2a20533e7b 100644 --- a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToAfterColumnBatPastFine.yml +++ b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToAfterBatVerticalPastFine.yml @@ -1,7 +1,7 @@ -languageId: markdown +languageId: plaintext command: version: 1 - spokenForm: bring air to after column bat past fine + spokenForm: bring air to after bat vertical past fine action: replaceWithTarget targets: - type: primitive @@ -10,13 +10,13 @@ command: start: type: primitive position: after - selectionType: column mark: {type: decoratedSymbol, symbolColor: default, character: b} end: type: primitive mark: {type: decoratedSymbol, symbolColor: default, character: f} excludeStart: false excludeEnd: false + rangeType: vertical initialState: documentContents: | a @@ -57,4 +57,4 @@ finalState: sourceMark: - anchor: {line: 0, character: 0} active: {line: 0, character: 1} -fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: column, position: after, insideOutsideType: null, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: column, position: after, insideOutsideType: null, modifier: {type: identity}}}] +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: after, insideOutsideType: null, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: after, insideOutsideType: null, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToColumnBatPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToBatVerticalPastFine.yml similarity index 73% rename from src/test/suite/fixtures/recorded/selectionTypes/bringAirToColumnBatPastFine.yml rename to src/test/suite/fixtures/recorded/compoundTargets/bringAirToBatVerticalPastFine.yml index ccc1632363..0faa14173f 100644 --- a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToColumnBatPastFine.yml +++ b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToBatVerticalPastFine.yml @@ -1,7 +1,7 @@ -languageId: markdown +languageId: plaintext command: version: 1 - spokenForm: bring air to column bat past fine + spokenForm: bring air to bat vertical past fine action: replaceWithTarget targets: - type: primitive @@ -9,13 +9,13 @@ command: - type: range start: type: primitive - selectionType: column mark: {type: decoratedSymbol, symbolColor: default, character: b} end: type: primitive mark: {type: decoratedSymbol, symbolColor: default, character: f} excludeStart: false excludeEnd: false + rangeType: vertical initialState: documentContents: | a @@ -56,4 +56,4 @@ finalState: sourceMark: - anchor: {line: 0, character: 0} active: {line: 0, character: 1} -fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: column, position: contents, insideOutsideType: null, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: column, position: contents, insideOutsideType: null, modifier: {type: identity}}}] +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToBeforeColumnBatPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToBeforeBatVerticalPastFine.yml similarity index 73% rename from src/test/suite/fixtures/recorded/selectionTypes/bringAirToBeforeColumnBatPastFine.yml rename to src/test/suite/fixtures/recorded/compoundTargets/bringAirToBeforeBatVerticalPastFine.yml index c572635ce5..2a8b817e95 100644 --- a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToBeforeColumnBatPastFine.yml +++ b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToBeforeBatVerticalPastFine.yml @@ -1,7 +1,7 @@ -languageId: markdown +languageId: plaintext command: version: 1 - spokenForm: bring air to before column bat past fine + spokenForm: bring air to before bat vertical past fine action: replaceWithTarget targets: - type: primitive @@ -10,13 +10,13 @@ command: start: type: primitive position: before - selectionType: column mark: {type: decoratedSymbol, symbolColor: default, character: b} end: type: primitive mark: {type: decoratedSymbol, symbolColor: default, character: f} excludeStart: false excludeEnd: false + rangeType: vertical initialState: documentContents: | a @@ -57,4 +57,4 @@ finalState: sourceMark: - anchor: {line: 0, character: 0} active: {line: 0, character: 1} -fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: column, position: before, insideOutsideType: null, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: column, position: before, insideOutsideType: null, modifier: {type: identity}}}] +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: before, insideOutsideType: null, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: before, insideOutsideType: null, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToEndOfColumnBatPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToEndOfBatVerticalPastFine.yml similarity index 74% rename from src/test/suite/fixtures/recorded/selectionTypes/bringAirToEndOfColumnBatPastFine.yml rename to src/test/suite/fixtures/recorded/compoundTargets/bringAirToEndOfBatVerticalPastFine.yml index 2146a254dd..17b8ac50bf 100644 --- a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToEndOfColumnBatPastFine.yml +++ b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToEndOfBatVerticalPastFine.yml @@ -1,7 +1,7 @@ -languageId: markdown +languageId: plaintext command: version: 1 - spokenForm: bring air to end of column bat past fine + spokenForm: bring air to end of bat vertical past fine action: replaceWithTarget targets: - type: primitive @@ -11,13 +11,13 @@ command: type: primitive position: after insideOutsideType: inside - selectionType: column mark: {type: decoratedSymbol, symbolColor: default, character: b} end: type: primitive mark: {type: decoratedSymbol, symbolColor: default, character: f} excludeStart: false excludeEnd: false + rangeType: vertical initialState: documentContents: | a @@ -58,4 +58,4 @@ finalState: sourceMark: - anchor: {line: 0, character: 0} active: {line: 0, character: 1} -fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: column, position: after, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: column, position: after, insideOutsideType: inside, modifier: {type: identity}}}] +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: after, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: after, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToStartOfColumnBatPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToStartOfBatVerticalPastFine.yml similarity index 74% rename from src/test/suite/fixtures/recorded/selectionTypes/bringAirToStartOfColumnBatPastFine.yml rename to src/test/suite/fixtures/recorded/compoundTargets/bringAirToStartOfBatVerticalPastFine.yml index 5ac8f7bc52..b58f960343 100644 --- a/src/test/suite/fixtures/recorded/selectionTypes/bringAirToStartOfColumnBatPastFine.yml +++ b/src/test/suite/fixtures/recorded/compoundTargets/bringAirToStartOfBatVerticalPastFine.yml @@ -1,7 +1,7 @@ -languageId: markdown +languageId: plaintext command: version: 1 - spokenForm: bring air to start of column bat past fine + spokenForm: bring air to start of bat vertical past fine action: replaceWithTarget targets: - type: primitive @@ -11,13 +11,13 @@ command: type: primitive position: before insideOutsideType: inside - selectionType: column mark: {type: decoratedSymbol, symbolColor: default, character: b} end: type: primitive mark: {type: decoratedSymbol, symbolColor: default, character: f} excludeStart: false excludeEnd: false + rangeType: vertical initialState: documentContents: | a @@ -58,4 +58,4 @@ finalState: sourceMark: - anchor: {line: 0, character: 0} active: {line: 0, character: 1} -fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: column, position: before, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: column, position: before, insideOutsideType: inside, modifier: {type: identity}}}] +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}}, {type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: before, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: before, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/compoundTargets/postBatVerticalUntilFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/postBatVerticalUntilFine.yml new file mode 100644 index 0000000000..85fc3a0d20 --- /dev/null +++ b/src/test/suite/fixtures/recorded/compoundTargets/postBatVerticalUntilFine.yml @@ -0,0 +1,51 @@ +languageId: plaintext +command: + version: 1 + spokenForm: post bat vertical until fine + action: setSelectionAfter + targets: + - type: range + start: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: b} + end: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + excludeStart: false + excludeEnd: true + rangeType: vertical +initialState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} + marks: + default.b: + start: {line: 2, character: 0} + end: {line: 2, character: 1} + default.f: + start: {line: 4, character: 0} + end: {line: 4, character: 1} +finalState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 2, character: 1} + active: {line: 2, character: 1} + - anchor: {line: 3, character: 1} + active: {line: 3, character: 1} + thatMark: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 1} + - anchor: {line: 3, character: 0} + active: {line: 3, character: 1} +fullTargets: [{type: range, excludeAnchor: false, excludeActive: true, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/compoundTargets/preBatVerticalBetweenFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/preBatVerticalBetweenFine.yml new file mode 100644 index 0000000000..cf9ad1e1d7 --- /dev/null +++ b/src/test/suite/fixtures/recorded/compoundTargets/preBatVerticalBetweenFine.yml @@ -0,0 +1,47 @@ +languageId: plaintext +command: + version: 1 + spokenForm: pre bat vertical between fine + action: setSelectionBefore + targets: + - type: range + start: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: b} + end: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + excludeStart: true + excludeEnd: true + rangeType: vertical +initialState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} + marks: + default.b: + start: {line: 2, character: 0} + end: {line: 2, character: 1} + default.f: + start: {line: 4, character: 0} + end: {line: 4, character: 1} +finalState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 0} + thatMark: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 1} +fullTargets: [{type: range, excludeAnchor: true, excludeActive: true, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/compoundTargets/takeBatVerticalPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/takeBatVerticalPastFine.yml new file mode 100644 index 0000000000..723d591faa --- /dev/null +++ b/src/test/suite/fixtures/recorded/compoundTargets/takeBatVerticalPastFine.yml @@ -0,0 +1,55 @@ +languageId: plaintext +command: + version: 1 + spokenForm: take bat vertical past fine + action: setSelection + targets: + - type: range + start: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: b} + end: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + excludeStart: false + excludeEnd: false + rangeType: vertical +initialState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} + marks: + default.b: + start: {line: 2, character: 0} + end: {line: 2, character: 1} + default.f: + start: {line: 4, character: 0} + end: {line: 4, character: 1} +finalState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 1} + - anchor: {line: 3, character: 0} + active: {line: 3, character: 1} + - anchor: {line: 4, character: 0} + active: {line: 4, character: 1} + thatMark: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 1} + - anchor: {line: 3, character: 0} + active: {line: 3, character: 1} + - anchor: {line: 4, character: 0} + active: {line: 4, character: 1} +fullTargets: [{type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/compoundTargets/takeFineVerticalPastBat.yml b/src/test/suite/fixtures/recorded/compoundTargets/takeFineVerticalPastBat.yml new file mode 100644 index 0000000000..40a19b1632 --- /dev/null +++ b/src/test/suite/fixtures/recorded/compoundTargets/takeFineVerticalPastBat.yml @@ -0,0 +1,55 @@ +languageId: typescript +command: + version: 1 + spokenForm: take fine vertical past bat + action: setSelection + targets: + - type: range + start: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + end: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: b} + excludeStart: false + excludeEnd: false + rangeType: vertical +initialState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} + marks: + default.f: + start: {line: 4, character: 0} + end: {line: 4, character: 1} + default.b: + start: {line: 2, character: 0} + end: {line: 2, character: 1} +finalState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 4, character: 0} + active: {line: 4, character: 1} + - anchor: {line: 3, character: 0} + active: {line: 3, character: 1} + - anchor: {line: 2, character: 0} + active: {line: 2, character: 1} + thatMark: + - anchor: {line: 4, character: 0} + active: {line: 4, character: 1} + - anchor: {line: 3, character: 0} + active: {line: 3, character: 1} + - anchor: {line: 2, character: 0} + active: {line: 2, character: 1} +fullTargets: [{type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: b}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/compoundTargets/takeVerticalPastFine.yml b/src/test/suite/fixtures/recorded/compoundTargets/takeVerticalPastFine.yml new file mode 100644 index 0000000000..40aa3c77e0 --- /dev/null +++ b/src/test/suite/fixtures/recorded/compoundTargets/takeVerticalPastFine.yml @@ -0,0 +1,50 @@ +languageId: typescript +command: + version: 1 + spokenForm: take vertical past fine + action: setSelection + targets: + - type: range + start: {type: primitive} + end: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + excludeStart: false + excludeEnd: false + rangeType: vertical +initialState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 2, character: 1} + active: {line: 2, character: 0} + marks: + default.f: + start: {line: 4, character: 0} + end: {line: 4, character: 1} +finalState: + documentContents: | + a + + b c + d e + f g + selections: + - anchor: {line: 2, character: 1} + active: {line: 2, character: 0} + - anchor: {line: 3, character: 1} + active: {line: 3, character: 0} + - anchor: {line: 4, character: 1} + active: {line: 4, character: 0} + thatMark: + - anchor: {line: 2, character: 1} + active: {line: 2, character: 0} + - anchor: {line: 3, character: 1} + active: {line: 3, character: 0} + - anchor: {line: 4, character: 1} + active: {line: 4, character: 0} +fullTargets: [{type: range, excludeAnchor: false, excludeActive: false, rangeType: vertical, anchor: {type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/postColumnWhaleUntilEach.yml b/src/test/suite/fixtures/recorded/selectionTypes/postColumnWhaleUntilEach.yml deleted file mode 100644 index 50e59e9d65..0000000000 --- a/src/test/suite/fixtures/recorded/selectionTypes/postColumnWhaleUntilEach.yml +++ /dev/null @@ -1,53 +0,0 @@ -languageId: markdown -command: - version: 1 - spokenForm: post column whale until each - action: setSelectionAfter - targets: - - type: range - start: - type: primitive - selectionType: column - mark: {type: decoratedSymbol, symbolColor: default, character: w} - end: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - excludeStart: false - excludeEnd: true -initialState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 0, character: 6} - active: {line: 0, character: 6} - marks: - default.w: - start: {line: 0, character: 6} - end: {line: 0, character: 11} - default.e: - start: {line: 3, character: 8} - end: {line: 3, character: 12} -finalState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - - anchor: {line: 1, character: 8} - active: {line: 1, character: 8} - - anchor: {line: 2, character: 11} - active: {line: 2, character: 11} - thatMark: - - anchor: {line: 0, character: 6} - active: {line: 0, character: 11} - - anchor: {line: 1, character: 6} - active: {line: 1, character: 11} - - anchor: {line: 2, character: 6} - active: {line: 2, character: 11} -fullTargets: [{type: range, excludeAnchor: false, excludeActive: true, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: w}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnAirPastEach.yml b/src/test/suite/fixtures/recorded/selectionTypes/takeColumnAirPastEach.yml deleted file mode 100644 index 6d4a34d8f8..0000000000 --- a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnAirPastEach.yml +++ /dev/null @@ -1,57 +0,0 @@ -languageId: markdown -command: - version: 1 - spokenForm: take column air past each - action: setSelection - targets: - - type: range - start: - type: primitive - selectionType: column - mark: {type: decoratedSymbol, symbolColor: default, character: a} - end: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - excludeStart: false - excludeEnd: false -initialState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} - marks: - default.a: - start: {line: 3, character: 0} - end: {line: 3, character: 3} - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 3, character: 0} - active: {line: 3, character: 3} - - anchor: {line: 2, character: 0} - active: {line: 2, character: 3} - - anchor: {line: 1, character: 0} - active: {line: 1, character: 3} - - anchor: {line: 0, character: 0} - active: {line: 0, character: 3} - thatMark: - - anchor: {line: 3, character: 0} - active: {line: 3, character: 3} - - anchor: {line: 2, character: 0} - active: {line: 2, character: 3} - - anchor: {line: 1, character: 0} - active: {line: 1, character: 3} - - anchor: {line: 0, character: 0} - active: {line: 0, character: 3} -fullTargets: [{type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnLookPastAir.yml b/src/test/suite/fixtures/recorded/selectionTypes/takeColumnLookPastAir.yml deleted file mode 100644 index bc3612ee2d..0000000000 --- a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnLookPastAir.yml +++ /dev/null @@ -1,57 +0,0 @@ -languageId: markdown -command: - version: 1 - spokenForm: take column look past air - action: setSelection - targets: - - type: range - start: - type: primitive - selectionType: column - mark: {type: decoratedSymbol, symbolColor: default, character: l} - end: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: a} - excludeStart: false - excludeEnd: false -initialState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 0, character: 6} - active: {line: 0, character: 6} - marks: - default.l: - start: {line: 0, character: 0} - end: {line: 0, character: 5} - default.a: - start: {line: 3, character: 0} - end: {line: 3, character: 3} -finalState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} - - anchor: {line: 1, character: 0} - active: {line: 1, character: 5} - - anchor: {line: 2, character: 0} - active: {line: 2, character: 5} - - anchor: {line: 3, character: 0} - active: {line: 3, character: 5} - thatMark: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} - - anchor: {line: 1, character: 0} - active: {line: 1, character: 5} - - anchor: {line: 2, character: 0} - active: {line: 2, character: 5} - - anchor: {line: 3, character: 0} - active: {line: 3, character: 5} -fullTargets: [{type: range, excludeAnchor: false, excludeActive: false, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: l}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnUntilEach.yml b/src/test/suite/fixtures/recorded/selectionTypes/takeColumnUntilEach.yml deleted file mode 100644 index fe93e6e5a8..0000000000 --- a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnUntilEach.yml +++ /dev/null @@ -1,47 +0,0 @@ -languageId: markdown -command: - version: 1 - spokenForm: take column until each - action: setSelection - targets: - - type: range - start: {type: primitive, selectionType: column} - end: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - excludeStart: false - excludeEnd: true -initialState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 3, character: 2} - active: {line: 3, character: 1} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 3, character: 2} - active: {line: 3, character: 1} - - anchor: {line: 2, character: 2} - active: {line: 2, character: 1} - - anchor: {line: 1, character: 2} - active: {line: 1, character: 1} - thatMark: - - anchor: {line: 3, character: 2} - active: {line: 3, character: 1} - - anchor: {line: 2, character: 2} - active: {line: 2, character: 1} - - anchor: {line: 1, character: 2} - active: {line: 1, character: 1} -fullTargets: [{type: range, excludeAnchor: false, excludeActive: true, anchor: {type: primitive, mark: {type: cursor}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnWhaleBetweenRam.yml b/src/test/suite/fixtures/recorded/selectionTypes/takeColumnWhaleBetweenRam.yml deleted file mode 100644 index 28f8fcedda..0000000000 --- a/src/test/suite/fixtures/recorded/selectionTypes/takeColumnWhaleBetweenRam.yml +++ /dev/null @@ -1,49 +0,0 @@ -languageId: markdown -command: - version: 1 - spokenForm: take column whale between ram - action: setSelection - targets: - - type: range - start: - type: primitive - selectionType: column - mark: {type: decoratedSymbol, symbolColor: default, character: w} - end: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: r} - excludeStart: true - excludeEnd: true -initialState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 4, character: 0} - active: {line: 4, character: 0} - marks: - default.w: - start: {line: 0, character: 6} - end: {line: 0, character: 11} - default.r: - start: {line: 3, character: 8} - end: {line: 3, character: 12} -finalState: - documentContents: | - hello world ! - hi there - Second things to say - and I'm here - selections: - - anchor: {line: 1, character: 6} - active: {line: 1, character: 8} - - anchor: {line: 2, character: 6} - active: {line: 2, character: 11} - thatMark: - - anchor: {line: 1, character: 6} - active: {line: 1, character: 11} - - anchor: {line: 2, character: 6} - active: {line: 2, character: 11} -fullTargets: [{type: range, excludeAnchor: true, excludeActive: true, anchor: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: w}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}, active: {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: r}, selectionType: column, position: contents, insideOutsideType: inside, modifier: {type: identity}}}] diff --git a/src/test/suite/fixtures/recorded/surroundingPair/parseTree/typescript/clearPair8.yml b/src/test/suite/fixtures/recorded/surroundingPair/parseTree/typescript/clearPair8.yml index 1f1c35d77a..f48515a465 100644 --- a/src/test/suite/fixtures/recorded/surroundingPair/parseTree/typescript/clearPair8.yml +++ b/src/test/suite/fixtures/recorded/surroundingPair/parseTree/typescript/clearPair8.yml @@ -1,6 +1,6 @@ languageId: typescript command: - version: 0 + version: 1 spokenForm: clear pair action: clearAndSetSelection targets: diff --git a/src/typings/Types.ts b/src/typings/Types.ts index f53a9833ad..93c411c4b4 100644 --- a/src/typings/Types.ts +++ b/src/typings/Types.ts @@ -174,7 +174,7 @@ export type Modifier = export type SelectionType = // | "character" Not implemented - "token" | "line" | "notebookCell" | "paragraph" | "document" | "column"; + "token" | "line" | "notebookCell" | "paragraph" | "document"; export type Position = "before" | "after" | "contents"; @@ -195,6 +195,7 @@ export interface PartialRangeTarget { end: PartialPrimitiveTarget; excludeStart?: boolean; excludeEnd?: boolean; + rangeType?: RangeType; } export interface PartialListTarget { @@ -222,8 +223,13 @@ export interface RangeTarget { active: PrimitiveTarget; excludeAnchor: boolean; excludeActive: boolean; + rangeType: RangeType; } +// continuous is one single continuous selection between the two targets +// vertical puts a selection on each line vertically between the two targets +export type RangeType = "continuous" | "vertical"; + export interface ListTarget { type: "list"; elements: (PrimitiveTarget | RangeTarget)[];