File tree 5 files changed +73
-9
lines changed
recorded/languages/typescript
common/src/scopeSupportFacets
cursorless-engine/src/processTargets/modifiers
5 files changed +73
-9
lines changed Original file line number Diff line number Diff line change @@ -23,5 +23,5 @@ finalState:
23
23
24
24
const value = { a: 1, b: 2, c: 3 };
25
25
selections :
26
- - anchor : {line: 1, character: 0 }
27
- active : {line: 1, character: 35 }
26
+ - anchor : {line: 1, character: 6 }
27
+ active : {line: 1, character: 34 }
Original file line number Diff line number Diff line change
1
+ let foo, bar;
2
+ ---
3
+
4
+ [#1 Content] =
5
+ [#1 Domain] = 0:4-0:7
6
+ >---<
7
+ 0| let foo, bar;
8
+
9
+ [#1 Removal] = 0:4-0:9
10
+ >-----<
11
+ 0| let foo, bar;
12
+
13
+ [#1 Trailing delimiter] = 0:7-0:9
14
+ >--<
15
+ 0| let foo, bar;
16
+
17
+ [#1 Insertion delimiter] = ", "
18
+
19
+
20
+ [#2 Content] =
21
+ [#2 Domain] = 0:9-0:12
22
+ >---<
23
+ 0| let foo, bar;
24
+
25
+ [#2 Removal] = 0:7-0:12
26
+ >-----<
27
+ 0| let foo, bar;
28
+
29
+ [#2 Leading delimiter] = 0:7-0:9
30
+ >--<
31
+ 0| let foo, bar;
32
+
33
+ [#2 Insertion delimiter] = ", "
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = {
112
112
"value.return" : supported ,
113
113
"value.return.lambda" : supported ,
114
114
"value.field" : supported ,
115
+
116
+ "collectionItem.unenclosed" : supported ,
115
117
} ;
116
118
117
119
export const javascriptJsxScopeSupport : LanguageScopeSupportFacetMap = {
Original file line number Diff line number Diff line change @@ -45,23 +45,39 @@ export class ContainingScopeStage implements ModifierStage {
45
45
. run ( target ) ;
46
46
}
47
47
48
- const containingScope = getContainingScopeTarget (
48
+ const containingScopes = getContainingScopeTarget (
49
49
target ,
50
50
scopeHandler ,
51
51
ancestorIndex ,
52
52
) ;
53
-
54
- if ( containingScope == null ) {
55
- if ( scopeType . type === "collectionItem" ) {
56
- // For `collectionItem`, fall back to generic implementation
57
- return this . modifierStageFactory
53
+ if ( scopeType . type === "collectionItem" ) {
54
+ // For `collectionItem`, combine with generic implementation
55
+ try {
56
+ const legacyScopes = this . modifierStageFactory
58
57
. getLegacyScopeStage ( this . modifier )
59
58
. run ( target ) ;
59
+ if ( containingScopes == null ) {
60
+ return legacyScopes ;
61
+ }
62
+ if ( containingScopes . length === 1 && legacyScopes . length === 1 ) {
63
+ const containingRange = containingScopes [ 0 ] . contentRange ;
64
+ const legacyRange = legacyScopes [ 0 ] . contentRange ;
65
+ if (
66
+ containingRange . contains ( legacyRange ) &&
67
+ ! containingRange . isRangeEqual ( legacyRange )
68
+ ) {
69
+ return legacyScopes ;
70
+ }
71
+ }
72
+ } catch ( _ex ) {
73
+ // Do nothing
60
74
}
75
+ }
61
76
77
+ if ( containingScopes == null ) {
62
78
throw new NoContainingScopeError ( this . modifier . scopeType . type ) ;
63
79
}
64
80
65
- return containingScope ;
81
+ return containingScopes ;
66
82
}
67
83
}
Original file line number Diff line number Diff line change 272
272
(#has-multiple-children-of-type? @_dummy variable_declarator)
273
273
)
274
274
275
+ ; ;!! let foo, bar;
276
+ ; ;! ^^^ ^^^
277
+ (
278
+ (lexical_declaration
279
+ (variable_declarator)? @_.leading.endOf
280
+ .
281
+ (variable_declarator) @collectionItem
282
+ .
283
+ (variable_declarator)? @_.trailing.startOf
284
+ )
285
+ (#insertion-delimiter! @collectionItem " , " )
286
+ )
287
+
275
288
(expression_statement
276
289
[
277
290
; ; name:
You can’t perform that action at this time.
0 commit comments