File tree Expand file tree Collapse file tree 4 files changed +94
-2
lines changed
data/fixtures/recorded/actions
packages/cursorless-engine/src Expand file tree Collapse file tree 4 files changed +94
-2
lines changed Original file line number Diff line number Diff line change
1
+ languageId : plaintext
2
+ command :
3
+ version : 7
4
+ spokenForm : bring token to line
5
+ action :
6
+ name : replaceWithTarget
7
+ source :
8
+ type : primitive
9
+ modifiers :
10
+ - type : containingScope
11
+ scopeType : {type: token}
12
+ destination :
13
+ type : primitive
14
+ insertionMode : to
15
+ target :
16
+ type : primitive
17
+ modifiers :
18
+ - type : containingScope
19
+ scopeType : {type: line}
20
+ usePrePhraseSnapshot : false
21
+ initialState :
22
+ documentContents : a b c
23
+ selections :
24
+ - anchor : {line: 0, character: 2}
25
+ active : {line: 0, character: 2}
26
+ marks : {}
27
+ finalState :
28
+ documentContents : b
29
+ selections :
30
+ - anchor : {line: 0, character: 1}
31
+ active : {line: 0, character: 1}
32
+ thatMark :
33
+ - type : UntypedTarget
34
+ contentRange :
35
+ start : {line: 0, character: 0}
36
+ end : {line: 0, character: 1}
37
+ isReversed : false
38
+ hasExplicitRange : true
39
+ sourceMark :
40
+ - type : UntypedTarget
41
+ contentRange :
42
+ start : {line: 0, character: 1}
43
+ end : {line: 0, character: 1}
44
+ isReversed : false
45
+ hasExplicitRange : true
Original file line number Diff line number Diff line change
1
+ languageId : plaintext
2
+ command :
3
+ version : 7
4
+ spokenForm : move token to line
5
+ action :
6
+ name : moveToTarget
7
+ source :
8
+ type : primitive
9
+ modifiers :
10
+ - type : containingScope
11
+ scopeType : {type: token}
12
+ destination :
13
+ type : primitive
14
+ insertionMode : to
15
+ target :
16
+ type : primitive
17
+ modifiers :
18
+ - type : containingScope
19
+ scopeType : {type: line}
20
+ usePrePhraseSnapshot : false
21
+ initialState :
22
+ documentContents : a b c
23
+ selections :
24
+ - anchor : {line: 0, character: 2}
25
+ active : {line: 0, character: 2}
26
+ marks : {}
27
+ finalState :
28
+ documentContents : b
29
+ selections :
30
+ - anchor : {line: 0, character: 1}
31
+ active : {line: 0, character: 1}
32
+ thatMark :
33
+ - type : UntypedTarget
34
+ contentRange :
35
+ start : {line: 0, character: 0}
36
+ end : {line: 0, character: 1}
37
+ isReversed : false
38
+ hasExplicitRange : true
39
+ sourceMark : []
Original file line number Diff line number Diff line change @@ -103,7 +103,13 @@ abstract class BringMoveSwap {
103
103
// Add source edit
104
104
// Prevent multiple instances of the same expanded source.
105
105
if ( ! usedSources . includes ( source ) ) {
106
- usedSources . push ( source ) ;
106
+ // Allow move where the destination contains the source. eg "bring token to line"
107
+ if (
108
+ this . type !== "move" ||
109
+ ! destination . target . getRemovalRange ( ) . contains ( source . contentRange )
110
+ ) {
111
+ usedSources . push ( source ) ;
112
+ }
107
113
if ( this . type === "bring" ) {
108
114
results . push ( {
109
115
edit : source
Original file line number Diff line number Diff line change @@ -56,5 +56,7 @@ function mergeTargets(targets: Target[]): Target {
56
56
}
57
57
58
58
function intersects ( targetA : Target , targetB : Target ) {
59
- return ! ! targetA . getRemovalRange ( ) . intersection ( targetB . getRemovalRange ( ) ) ;
59
+ return (
60
+ targetA . getRemovalRange ( ) . intersection ( targetB . getRemovalRange ( ) ) != null
61
+ ) ;
60
62
}
You can’t perform that action at this time.
0 commit comments