File tree Expand file tree Collapse file tree 10 files changed +77
-29
lines changed
cursorless-vscode-e2e/src/suite/fixtures/recorded/languages Expand file tree Collapse file tree 10 files changed +77
-29
lines changed Original file line number Diff line number Diff line change @@ -57,16 +57,14 @@ export function elseIfExtractor(): SelectionExtractor {
57
57
}
58
58
59
59
// If we get here, we are part of a bigger `if` statement; extend our
60
- // removal range past our leading `else` keyword.
60
+ // content range past our leading `else` keyword.
61
61
const { selection } = contentRange ;
62
62
return {
63
- selection,
64
- context : {
65
- removalRange : new Selection (
66
- positionFromPoint ( parent . child ( 0 ) ! . startPosition ) ,
67
- selection . end ,
68
- ) ,
69
- } ,
63
+ selection : new Selection (
64
+ positionFromPoint ( parent . child ( 0 ) ! . startPosition ) ,
65
+ selection . end ,
66
+ ) ,
67
+ context : { } ,
70
68
} ;
71
69
} ;
72
70
}
Original file line number Diff line number Diff line change @@ -110,15 +110,25 @@ export class DestinationImpl implements Destination {
110
110
111
111
private getEditRange ( ) {
112
112
const position = ( ( ) => {
113
+ const contentPosition = this . isBefore
114
+ ? this . contentRange . start
115
+ : this . contentRange . end ;
116
+
113
117
if ( this . isLineDelimiter ) {
114
- const line = this . editor . document . lineAt (
115
- this . isBefore ? this . contentRange . start : this . contentRange . end ,
116
- ) ;
117
- return this . isBefore ? line . range . start : line . range . end ;
118
- } else {
119
- return this . isBefore ? this . contentRange . start : this . contentRange . end ;
118
+ const line = this . editor . document . lineAt ( contentPosition ) ;
119
+ const nonWhitespaceCharacterIndex = this . isBefore
120
+ ? line . firstNonWhitespaceCharacterIndex
121
+ : line . lastNonWhitespaceCharacterIndex ;
122
+
123
+ // Use the full line to include indentation
124
+ if ( contentPosition . character === nonWhitespaceCharacterIndex ) {
125
+ return this . isBefore ? line . range . start : line . range . end ;
126
+ }
120
127
}
128
+
129
+ return contentPosition ;
121
130
} ) ( ) ;
131
+
122
132
return new Range ( position , position ) ;
123
133
}
124
134
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ finalState:
26
26
documentContents : |-
27
27
if n < 0 {
28
28
print!("{} is negative", n);
29
- } else else {
29
+ } else {
30
30
print!("{} is zero", n);
31
31
}
32
32
selections :
33
- - anchor : {line: 2, character: 7 }
34
- active : {line: 2, character: 7 }
33
+ - anchor : {line: 2, character: 2 }
34
+ active : {line: 2, character: 2 }
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ finalState:
26
26
documentContents : |-
27
27
if n < 0 {
28
28
print!("{} is negative", n);
29
- } else else {
29
+ } else {
30
30
print!("{} is zero", n);
31
31
}
32
32
selections :
33
- - anchor : {line: 2, character: 7 }
34
- active : {line: 2, character: 7 }
33
+ - anchor : {line: 2, character: 2 }
34
+ active : {line: 2, character: 2 }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ finalState:
26
26
documentContents : |-
27
27
if n < 0 {
28
28
print!("{} is negative", n);
29
- } else {
29
+ } else {
30
30
print!("{} is zero", n);
31
31
}
32
32
selections :
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ finalState:
26
26
documentContents : |-
27
27
if (true) {
28
28
const whatever = "hello";
29
- } else else {
29
+ } else {
30
30
const whatever = "hello";
31
31
}
32
32
selections :
33
- - anchor : {line: 2, character: 7 }
34
- active : {line: 2, character: 7 }
33
+ - anchor : {line: 2, character: 2 }
34
+ active : {line: 2, character: 2 }
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ finalState:
26
26
documentContents : |-
27
27
if (true) {
28
28
const whatever = "hello";
29
- } else else {
29
+ } else {
30
30
const whatever = "hello";
31
31
}
32
32
selections :
33
- - anchor : {line: 2, character: 7 }
34
- active : {line: 2, character: 7 }
33
+ - anchor : {line: 2, character: 2 }
34
+ active : {line: 2, character: 2 }
Original file line number Diff line number Diff line change
1
+ languageId : typescript
2
+ command :
3
+ version : 6
4
+ spokenForm : clone branch
5
+ action :
6
+ name : insertCopyAfter
7
+ target :
8
+ type : primitive
9
+ modifiers :
10
+ - type : containingScope
11
+ scopeType : {type: branch}
12
+ usePrePhraseSnapshot : true
13
+ initialState :
14
+ documentContents : |-
15
+ if (1 > 0) {
16
+
17
+ } else if (1 > 2) {
18
+
19
+ } else {
20
+
21
+ }
22
+ selections :
23
+ - anchor : {line: 2, character: 2}
24
+ active : {line: 2, character: 2}
25
+ marks : {}
26
+ finalState :
27
+ documentContents : |-
28
+ if (1 > 0) {
29
+
30
+ } else if (1 > 2) {
31
+
32
+ }
33
+ else if (1 > 2) {
34
+
35
+ } else {
36
+
37
+ }
38
+ selections :
39
+ - anchor : {line: 5, character: 0}
40
+ active : {line: 5, character: 0}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ finalState:
26
26
documentContents : |-
27
27
if (true) {
28
28
const whatever = "hello";
29
- } else {
29
+ } else {
30
30
const whatever = "hello";
31
31
}
32
32
selections :
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ finalState:
26
26
documentContents : |-
27
27
if (true) {
28
28
const whatever = "hello";
29
- } else {
29
+ } else {
30
30
const whatever = "hello";
31
31
}
32
32
selections :
You can’t perform that action at this time.
0 commit comments