11import {
22 type Direction ,
3- Position ,
3+ type Position ,
44 Range ,
55 type ScopeType ,
6- type SurroundingPairName ,
76 type TextEditor ,
87} from "@cursorless/common" ;
98import { shrinkRangeToFitContent } from "../../../../util/selectionUtils" ;
@@ -17,6 +16,7 @@ import type {
1716import type { ScopeHandlerFactory } from "../ScopeHandlerFactory" ;
1817import { collectionItemIterationScopeHandler } from "./collectionItemIterationScopeHandler" ;
1918import { createTargetScope } from "./createTargetScope" ;
19+ import { getInteriorRanges } from "./getInteriorRanges" ;
2020import { getSeparatorOccurrences } from "./getSeparatorOccurrences" ;
2121
2222export class CollectionItemTextualScopeHandler extends BaseScopeHandler {
@@ -34,27 +34,6 @@ export class CollectionItemTextualScopeHandler extends BaseScopeHandler {
3434 super ( ) ;
3535 }
3636
37- private getInteriorRanges (
38- editor : TextEditor ,
39- delimiter : SurroundingPairName ,
40- ) : Range [ ] {
41- const scopeHandler = this . scopeHandlerFactory . create (
42- {
43- type : "surroundingPairInterior" ,
44- delimiter,
45- } ,
46- this . languageId ,
47- ) ;
48- return Array . from (
49- scopeHandler . generateScopes ( editor , new Position ( 0 , 0 ) , "forward" , {
50- containment : undefined ,
51- skipAncestorScopes : false ,
52- includeDescendantScopes : true ,
53- } ) ,
54- ( scope ) => scope . domain ,
55- ) ;
56- }
57-
5837 * generateScopeCandidates (
5938 editor : TextEditor ,
6039 position : Position ,
@@ -63,8 +42,18 @@ export class CollectionItemTextualScopeHandler extends BaseScopeHandler {
6342 ) : Iterable < TargetScope > {
6443 const isEveryScope = hints . containment == null && hints . skipAncestorScopes ;
6544 const separatorRanges = getSeparatorOccurrences ( editor . document ) ;
66- const interiorRanges = this . getInteriorRanges ( editor , "collectionBoundary" ) ;
67- const stringRanges = this . getInteriorRanges ( editor , "string" ) ;
45+ const interiorRanges = getInteriorRanges (
46+ this . scopeHandlerFactory ,
47+ this . languageId ,
48+ editor ,
49+ "collectionBoundary" ,
50+ ) ;
51+ const stringRanges = getInteriorRanges (
52+ this . scopeHandlerFactory ,
53+ this . languageId ,
54+ editor ,
55+ "string" ,
56+ ) ;
6857 const scopes : TargetScope [ ] = [ ] ;
6958 const usedInteriors = new Set < Range > ( ) ;
7059 const iterationStatesStack : IterationState [ ] = [ ] ;
0 commit comments