File tree Expand file tree Collapse file tree 5 files changed +23
-7
lines changed
packages/cursorless-engine/src/processTargets Expand file tree Collapse file tree 5 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,11 @@ import RelativeScopeStage from "./modifiers/RelativeScopeStage";
32
32
import SurroundingPairStage from "./modifiers/SurroundingPairStage" ;
33
33
import { ScopeHandlerFactory } from "./modifiers/scopeHandlers/ScopeHandlerFactory" ;
34
34
import BoundedNonWhitespaceSequenceStage from "./modifiers/scopeTypeStages/BoundedNonWhitespaceStage" ;
35
- import ContainingSyntaxScopeStage , {
35
+ import {
36
+ LegacyContainingSyntaxScopeStage ,
36
37
SimpleContainingScopeModifier ,
37
38
SimpleEveryScopeModifier ,
38
- } from "./modifiers/scopeTypeStages/ContainingSyntaxScopeStage " ;
39
+ } from "./modifiers/scopeTypeStages/LegacyContainingSyntaxScopeStage " ;
39
40
import NotebookCellStage from "./modifiers/scopeTypeStages/NotebookCellStage" ;
40
41
41
42
export class ModifierStageFactoryImpl implements ModifierStageFactory {
@@ -142,7 +143,7 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
142
143
) ;
143
144
default :
144
145
// Default to containing syntax scope using tree sitter
145
- return new ContainingSyntaxScopeStage (
146
+ return new LegacyContainingSyntaxScopeStage (
146
147
this . languageDefinitions ,
147
148
modifier as SimpleContainingScopeModifier | SimpleEveryScopeModifier ,
148
149
) ;
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ export class ContainingScopeStage implements ModifierStage {
54
54
) ;
55
55
56
56
if ( containingScope == null ) {
57
+ if ( scopeType . type === "collectionItem" ) {
58
+ // For `collectionItem`, fall back to generic implementation
59
+ return this . modifierStageFactory
60
+ . getLegacyScopeStage ( this . modifier )
61
+ . run ( target ) ;
62
+ }
63
+
57
64
throw new NoContainingScopeError ( this . modifier . scopeType . type ) ;
58
65
}
59
66
Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ export class EveryScopeStage implements ModifierStage {
83
83
}
84
84
85
85
if ( scopes . length === 0 ) {
86
+ if ( scopeType . type === "collectionItem" ) {
87
+ // For `collectionItem`, fall back to generic implementation
88
+ return this . modifierStageFactory
89
+ . getLegacyScopeStage ( this . modifier )
90
+ . run ( target ) ;
91
+ }
92
+
86
93
throw new NoContainingScopeError ( scopeType . type ) ;
87
94
}
88
95
Original file line number Diff line number Diff line change @@ -12,9 +12,10 @@ import { getInsertionDelimiter } from "../../../util/nodeSelectors";
12
12
import { getRangeLength } from "../../../util/rangeUtils" ;
13
13
import { ModifierStage } from "../../PipelineStages.types" ;
14
14
import { ScopeTypeTarget } from "../../targets" ;
15
- import ContainingSyntaxScopeStage , {
15
+ import {
16
+ LegacyContainingSyntaxScopeStage ,
16
17
SimpleContainingScopeModifier ,
17
- } from "../scopeTypeStages/ContainingSyntaxScopeStage " ;
18
+ } from "../scopeTypeStages/LegacyContainingSyntaxScopeStage " ;
18
19
import { getIterationScope } from "./getIterationScope" ;
19
20
import { tokenizeRange } from "./tokenizeRange" ;
20
21
@@ -27,7 +28,7 @@ export default class ItemStage implements ModifierStage {
27
28
run ( target : Target ) : Target [ ] {
28
29
// First try the language specific implementation of item
29
30
try {
30
- return new ContainingSyntaxScopeStage (
31
+ return new LegacyContainingSyntaxScopeStage (
31
32
this . languageDefinitions ,
32
33
this . modifier as SimpleContainingScopeModifier ,
33
34
) . run ( target ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export interface SimpleEveryScopeModifier extends EveryScopeModifier {
25
25
scopeType : SimpleScopeType ;
26
26
}
27
27
28
- export default class implements ModifierStage {
28
+ export class LegacyContainingSyntaxScopeStage implements ModifierStage {
29
29
constructor (
30
30
private languageDefinitions : LanguageDefinitions ,
31
31
private modifier : SimpleContainingScopeModifier | SimpleEveryScopeModifier ,
You can’t perform that action at this time.
0 commit comments