Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions data/fixtures/recorded/actions/bringTokenToLine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
languageId: plaintext
command:
version: 7
spokenForm: bring token to line
action:
name: replaceWithTarget
source:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: token}
destination:
type: primitive
insertionMode: to
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: line}
usePrePhraseSnapshot: false
initialState:
documentContents: a b c
selections:
- anchor: {line: 0, character: 2}
active: {line: 0, character: 2}
marks: {}
finalState:
documentContents: b
selections:
- anchor: {line: 0, character: 1}
active: {line: 0, character: 1}
thatMark:
- type: UntypedTarget
contentRange:
start: {line: 0, character: 0}
end: {line: 0, character: 1}
isReversed: false
hasExplicitRange: true
sourceMark:
- type: UntypedTarget
contentRange:
start: {line: 0, character: 1}
end: {line: 0, character: 1}
isReversed: false
hasExplicitRange: true
39 changes: 39 additions & 0 deletions data/fixtures/recorded/actions/moveTokenToLine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
languageId: plaintext
command:
version: 7
spokenForm: move token to line
action:
name: moveToTarget
source:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: token}
destination:
type: primitive
insertionMode: to
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: line}
usePrePhraseSnapshot: false
initialState:
documentContents: a b c
selections:
- anchor: {line: 0, character: 2}
active: {line: 0, character: 2}
marks: {}
finalState:
documentContents: b
selections:
- anchor: {line: 0, character: 1}
active: {line: 0, character: 1}
thatMark:
- type: UntypedTarget
contentRange:
start: {line: 0, character: 0}
end: {line: 0, character: 1}
isReversed: false
hasExplicitRange: true
sourceMark: []
8 changes: 7 additions & 1 deletion packages/cursorless-engine/src/actions/BringMoveSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ abstract class BringMoveSwap {
// Add source edit
// Prevent multiple instances of the same expanded source.
if (!usedSources.includes(source)) {
usedSources.push(source);
// Allow move where the destination contains the source. eg "bring token to line"
if (
this.type !== "move" ||
!destination.target.getRemovalRange().contains(source.contentRange)
) {
usedSources.push(source);
}
if (this.type === "bring") {
results.push({
edit: source
Expand Down
4 changes: 3 additions & 1 deletion packages/cursorless-engine/src/util/unifyRanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@ function mergeTargets(targets: Target[]): Target {
}

function intersects(targetA: Target, targetB: Target) {
return !!targetA.getRemovalRange().intersection(targetB.getRemovalRange());
return (
targetA.getRemovalRange().intersection(targetB.getRemovalRange()) != null
);
}
Loading