@@ -56,7 +56,12 @@ export class ContiguousScopeHandler extends BaseScopeHandler {
56
56
position : Position ,
57
57
) : Iterable < TargetScope > {
58
58
let targetRangeForward = next (
59
- generateTargetRangesInDirection ( this . scopeHandler , editor , position , "forward" ) ,
59
+ generateTargetRangesInDirection (
60
+ this . scopeHandler ,
61
+ editor ,
62
+ position ,
63
+ "forward" ,
64
+ ) ,
60
65
) ;
61
66
62
67
const targetRangesBackwardIter = generateTargetRangesInDirection (
@@ -67,11 +72,14 @@ export class ContiguousScopeHandler extends BaseScopeHandler {
67
72
) ;
68
73
69
74
for ( const targetRange of targetRangesBackwardIter ) {
70
- if ( targetsForward != null && isAdjacent ( targets [ 1 ] , targetsForward [ 0 ] ) ) {
71
- yield targetsToScope ( targets [ 0 ] , targetsForward [ 1 ] ) ;
72
- targetsForward = undefined ;
75
+ if (
76
+ targetRangeForward != null &&
77
+ isAdjacent ( targetRange [ 1 ] , targetRangeForward [ 0 ] )
78
+ ) {
79
+ yield targetsToScope ( targetRange [ 0 ] , targetRangeForward [ 1 ] ) ;
80
+ targetRangeForward = undefined ;
73
81
} else {
74
- yield targetsToScope ( ...targets ) ;
82
+ yield targetsToScope ( ...targetRange ) ;
75
83
}
76
84
}
77
85
}
@@ -80,26 +88,31 @@ export class ContiguousScopeHandler extends BaseScopeHandler {
80
88
editor : TextEditor ,
81
89
position : Position ,
82
90
) : Iterable < TargetScope > {
83
- let targetsBackward = next (
84
- getTargetsInDirection ( this . scopeHandler , editor , position , "backward" ) ,
91
+ let targetRangeBackward = next (
92
+ generateTargetRangesInDirection (
93
+ this . scopeHandler ,
94
+ editor ,
95
+ position ,
96
+ "backward" ,
97
+ ) ,
85
98
) ;
86
99
87
- const targetsForward = getTargetsInDirection (
100
+ const targetRangesForwardIter = generateTargetRangesInDirection (
88
101
this . scopeHandler ,
89
102
editor ,
90
103
position ,
91
104
"forward" ,
92
105
) ;
93
106
94
- for ( const targets of targetsForward ) {
107
+ for ( const targetRange of targetRangesForwardIter ) {
95
108
if (
96
- targetsBackward != null &&
97
- isAdjacent ( targetsBackward [ 1 ] , targets [ 0 ] )
109
+ targetRangeBackward != null &&
110
+ isAdjacent ( targetRangeBackward [ 1 ] , targetRange [ 0 ] )
98
111
) {
99
- yield targetsToScope ( targetsBackward [ 0 ] , targets [ 1 ] ) ;
100
- targetsBackward = undefined ;
112
+ yield targetsToScope ( targetRangeBackward [ 0 ] , targetRange [ 1 ] ) ;
113
+ targetRangeBackward = undefined ;
101
114
} else {
102
- yield targetsToScope ( ...targets ) ;
115
+ yield targetsToScope ( ...targetRange ) ;
103
116
}
104
117
}
105
118
}
@@ -125,7 +138,7 @@ function targetsToScope(
125
138
} ;
126
139
}
127
140
128
- function * getTargetsInDirection (
141
+ function * generateTargetRangesInDirection (
129
142
scopeHandler : ScopeHandler ,
130
143
editor : TextEditor ,
131
144
position : Position ,
0 commit comments