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";
3232import SurroundingPairStage from "./modifiers/SurroundingPairStage" ;
3333import { ScopeHandlerFactory } from "./modifiers/scopeHandlers/ScopeHandlerFactory" ;
3434import BoundedNonWhitespaceSequenceStage from "./modifiers/scopeTypeStages/BoundedNonWhitespaceStage" ;
35- import ContainingSyntaxScopeStage , {
35+ import {
36+ LegacyContainingSyntaxScopeStage ,
3637 SimpleContainingScopeModifier ,
3738 SimpleEveryScopeModifier ,
38- } from "./modifiers/scopeTypeStages/ContainingSyntaxScopeStage " ;
39+ } from "./modifiers/scopeTypeStages/LegacyContainingSyntaxScopeStage " ;
3940import NotebookCellStage from "./modifiers/scopeTypeStages/NotebookCellStage" ;
4041
4142export class ModifierStageFactoryImpl implements ModifierStageFactory {
@@ -142,7 +143,7 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
142143 ) ;
143144 default :
144145 // Default to containing syntax scope using tree sitter
145- return new ContainingSyntaxScopeStage (
146+ return new LegacyContainingSyntaxScopeStage (
146147 this . languageDefinitions ,
147148 modifier as SimpleContainingScopeModifier | SimpleEveryScopeModifier ,
148149 ) ;
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ export class ContainingScopeStage implements ModifierStage {
5454 ) ;
5555
5656 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+
5764 throw new NoContainingScopeError ( this . modifier . scopeType . type ) ;
5865 }
5966
Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ export class EveryScopeStage implements ModifierStage {
8383 }
8484
8585 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+
8693 throw new NoContainingScopeError ( scopeType . type ) ;
8794 }
8895
Original file line number Diff line number Diff line change @@ -12,9 +12,10 @@ import { getInsertionDelimiter } from "../../../util/nodeSelectors";
1212import { getRangeLength } from "../../../util/rangeUtils" ;
1313import { ModifierStage } from "../../PipelineStages.types" ;
1414import { ScopeTypeTarget } from "../../targets" ;
15- import ContainingSyntaxScopeStage , {
15+ import {
16+ LegacyContainingSyntaxScopeStage ,
1617 SimpleContainingScopeModifier ,
17- } from "../scopeTypeStages/ContainingSyntaxScopeStage " ;
18+ } from "../scopeTypeStages/LegacyContainingSyntaxScopeStage " ;
1819import { getIterationScope } from "./getIterationScope" ;
1920import { tokenizeRange } from "./tokenizeRange" ;
2021
@@ -27,7 +28,7 @@ export default class ItemStage implements ModifierStage {
2728 run ( target : Target ) : Target [ ] {
2829 // First try the language specific implementation of item
2930 try {
30- return new ContainingSyntaxScopeStage (
31+ return new LegacyContainingSyntaxScopeStage (
3132 this . languageDefinitions ,
3233 this . modifier as SimpleContainingScopeModifier ,
3334 ) . run ( target ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export interface SimpleEveryScopeModifier extends EveryScopeModifier {
2525 scopeType : SimpleScopeType ;
2626}
2727
28- export default class implements ModifierStage {
28+ export class LegacyContainingSyntaxScopeStage implements ModifierStage {
2929 constructor (
3030 private languageDefinitions : LanguageDefinitions ,
3131 private modifier : SimpleContainingScopeModifier | SimpleEveryScopeModifier ,
You can’t perform that action at this time.
0 commit comments