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 {
251
251
export interface SurroundingPairInteriorScopeType {
252
252
type : "surroundingPairInterior" ;
253
253
delimiter : SurroundingPairName ;
254
+ // If true don't yield multiline pairs
255
+ requireSingleLine ?: boolean ;
254
256
}
255
257
256
258
export interface OneOfScopeType {
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ export class HeadTailStage implements ModifierStage {
27
27
{
28
28
type : "surroundingPairInterior" ,
29
29
delimiter : "any" ,
30
+ requireSingleLine : true ,
30
31
} ,
31
32
] ,
32
33
} ,
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import type { TargetScope } from "../scope.types";
5
5
import type { ScopeIteratorRequirements } from "../scopeHandler.types" ;
6
6
import { type ScopeHandler } from "../scopeHandler.types" ;
7
7
import type { ScopeHandlerFactory } from "../ScopeHandlerFactory" ;
8
- import { map } from "itertools" ;
9
8
10
9
export class SurroundingPairInteriorScopeHandler extends BaseScopeHandler {
11
10
protected isHierarchical = true ;
@@ -32,28 +31,33 @@ export class SurroundingPairInteriorScopeHandler extends BaseScopeHandler {
32
31
return this . surroundingPairScopeHandler . iterationScopeType ;
33
32
}
34
33
35
- generateScopeCandidates (
34
+ * generateScopeCandidates (
36
35
editor : TextEditor ,
37
36
position : Position ,
38
37
direction : Direction ,
39
38
hints : ScopeIteratorRequirements ,
40
39
) : 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 {
49
53
editor,
50
54
domain : scope . domain ,
51
55
getTargets ( isReversed ) {
52
56
return scope
53
57
. getTargets ( isReversed )
54
58
. flatMap ( ( target ) => target . getInterior ( ) ! ) ;
55
59
} ,
56
- } ) ,
57
- ) ;
60
+ } ;
61
+ }
58
62
}
59
63
}
You can’t perform that action at this time.
0 commit comments