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 {
5757 }
5858
5959 // 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.
6161 const { selection } = contentRange ;
6262 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 : { } ,
7068 } ;
7169 } ;
7270}
Original file line number Diff line number Diff line change @@ -110,15 +110,25 @@ export class DestinationImpl implements Destination {
110110
111111 private getEditRange ( ) {
112112 const position = ( ( ) => {
113+ const contentPosition = this . isBefore
114+ ? this . contentRange . start
115+ : this . contentRange . end ;
116+
113117 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+ }
120127 }
128+
129+ return contentPosition ;
121130 } ) ( ) ;
131+
122132 return new Range ( position , position ) ;
123133 }
124134
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ finalState:
2626 documentContents : |-
2727 if n < 0 {
2828 print!("{} is negative", n);
29- } else else {
29+ } else {
3030 print!("{} is zero", n);
3131 }
3232 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:
2626 documentContents : |-
2727 if n < 0 {
2828 print!("{} is negative", n);
29- } else else {
29+ } else {
3030 print!("{} is zero", n);
3131 }
3232 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:
2626 documentContents : |-
2727 if n < 0 {
2828 print!("{} is negative", n);
29- } else {
29+ } else {
3030 print!("{} is zero", n);
3131 }
3232 selections :
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ finalState:
2626 documentContents : |-
2727 if (true) {
2828 const whatever = "hello";
29- } else else {
29+ } else {
3030 const whatever = "hello";
3131 }
3232 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:
2626 documentContents : |-
2727 if (true) {
2828 const whatever = "hello";
29- } else else {
29+ } else {
3030 const whatever = "hello";
3131 }
3232 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:
2626 documentContents : |-
2727 if (true) {
2828 const whatever = "hello";
29- } else {
29+ } else {
3030 const whatever = "hello";
3131 }
3232 selections :
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ finalState:
2626 documentContents : |-
2727 if (true) {
2828 const whatever = "hello";
29- } else {
29+ } else {
3030 const whatever = "hello";
3131 }
3232 selections :
You can’t perform that action at this time.
0 commit comments