File tree Expand file tree Collapse file tree 4 files changed +47
-12
lines changed
data/fixtures/recorded/headTail
cursorless-engine/src/processTargets/modifiers
scopeHandlers/SurroundingPairScopeHandler Expand file tree Collapse file tree 4 files changed +47
-12
lines changed Original file line number Diff line number Diff line change 1+ languageId : python
2+ command :
3+ version : 7
4+ spokenForm : change tail
5+ action :
6+ name : clearAndSetSelection
7+ target :
8+ type : primitive
9+ modifiers :
10+ - {type: extendThroughEndOf}
11+ usePrePhraseSnapshot : true
12+ initialState :
13+ documentContents : |-
14+ """foo
15+ bar
16+ """
17+ selections :
18+ - anchor : {line: 0, character: 3}
19+ active : {line: 0, character: 3}
20+ marks : {}
21+ finalState :
22+ documentContents : |-
23+ """
24+ bar
25+ """
26+ selections :
27+ - anchor : {line: 0, character: 3}
28+ active : {line: 0, character: 3}
Original file line number Diff line number Diff line change @@ -251,6 +251,8 @@ export interface SurroundingPairScopeType {
251251export interface SurroundingPairInteriorScopeType {
252252 type : "surroundingPairInterior" ;
253253 delimiter : SurroundingPairName ;
254+ // If true don't yield multiline pairs
255+ requireSingleLine ?: boolean ;
254256}
255257
256258export interface OneOfScopeType {
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ export class HeadTailStage implements ModifierStage {
2727 {
2828 type : "surroundingPairInterior" ,
2929 delimiter : "any" ,
30+ requireSingleLine : true ,
3031 } ,
3132 ] ,
3233 } ,
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import type { TargetScope } from "../scope.types";
55import type { ScopeIteratorRequirements } from "../scopeHandler.types" ;
66import { type ScopeHandler } from "../scopeHandler.types" ;
77import type { ScopeHandlerFactory } from "../ScopeHandlerFactory" ;
8- import { map } from "itertools" ;
98
109export class SurroundingPairInteriorScopeHandler extends BaseScopeHandler {
1110 protected isHierarchical = true ;
@@ -32,28 +31,33 @@ export class SurroundingPairInteriorScopeHandler extends BaseScopeHandler {
3231 return this . surroundingPairScopeHandler . iterationScopeType ;
3332 }
3433
35- generateScopeCandidates (
34+ * generateScopeCandidates (
3635 editor : TextEditor ,
3736 position : Position ,
3837 direction : Direction ,
3938 hints : ScopeIteratorRequirements ,
4039 ) : Iterable < TargetScope > {
41- return map (
42- this . surroundingPairScopeHandler . generateScopes (
43- editor ,
44- position ,
45- direction ,
46- hints ,
47- ) ,
48- ( scope ) => ( {
40+ const scopes = this . surroundingPairScopeHandler . generateScopes (
41+ editor ,
42+ position ,
43+ direction ,
44+ hints ,
45+ ) ;
46+
47+ for ( const scope of scopes ) {
48+ if ( this . scopeType . requireSingleLine && ! scope . domain . isSingleLine ) {
49+ continue ;
50+ }
51+
52+ yield {
4953 editor,
5054 domain : scope . domain ,
5155 getTargets ( isReversed ) {
5256 return scope
5357 . getTargets ( isReversed )
5458 . flatMap ( ( target ) => target . getInterior ( ) ! ) ;
5559 } ,
56- } ) ,
57- ) ;
60+ } ;
61+ }
5862 }
5963}
You can’t perform that action at this time.
0 commit comments