@@ -155,9 +155,9 @@ fn find_nth_closest_pairs_plain(
155
155
}
156
156
157
157
pub enum FindType {
158
- Surround ( usize ) ,
159
- Next ( usize ) ,
160
- Prev ( usize ) ,
158
+ Surround ,
159
+ Next ,
160
+ Prev ,
161
161
}
162
162
163
163
/// Find the position of surround pairs of `ch` which can be either a closing
@@ -168,6 +168,7 @@ pub fn find_nth_pairs_pos(
168
168
ch : char ,
169
169
range : Range ,
170
170
find_type : FindType ,
171
+ n : usize ,
171
172
) -> Result < ( usize , usize ) > {
172
173
if text. len_chars ( ) < 2 {
173
174
return Err ( Error :: PairNotFound ) ;
@@ -179,12 +180,12 @@ pub fn find_nth_pairs_pos(
179
180
let ( open, close) = get_pair ( ch) ;
180
181
let pos = range. cursor ( text) ;
181
182
let ( pos, n) = match find_type {
182
- FindType :: Surround ( n ) => ( pos, n) ,
183
- FindType :: Next ( n ) => match search:: find_nth_next ( text, open, pos, n) {
183
+ FindType :: Surround => ( pos, n) ,
184
+ FindType :: Next => match search:: find_nth_next ( text, open, pos, n) {
184
185
Some ( next_pos) => ( next_pos + 1 , 1 ) ,
185
186
None => return Err ( Error :: PairNotFound ) ,
186
187
} ,
187
- FindType :: Prev ( n ) => match search:: find_nth_prev ( text, close, pos, n) {
188
+ FindType :: Prev => match search:: find_nth_prev ( text, close, pos, n) {
188
189
Some ( next_pos) => ( next_pos - 1 , 1 ) ,
189
190
None => return Err ( Error :: PairNotFound ) ,
190
191
} ,
@@ -315,7 +316,7 @@ pub fn get_surround_pos(
315
316
for & range in selection {
316
317
let ( open_pos, close_pos) = {
317
318
let range_raw = match ch {
318
- Some ( ch) => find_nth_pairs_pos ( text, ch, range, FindType :: Surround ( skip) ) ?,
319
+ Some ( ch) => find_nth_pairs_pos ( text, ch, range, FindType :: Surround , skip) ?,
319
320
None => find_nth_closest_pairs_pos ( syntax, text, range, skip) ?,
320
321
} ;
321
322
let range = Range :: new ( range_raw. 0 , range_raw. 1 ) ;
@@ -413,7 +414,8 @@ mod test {
413
414
doc. slice( ..) ,
414
415
'\'' ,
415
416
selection. primary( ) ,
416
- FindType :: Surround ( 1 )
417
+ FindType :: Surround ,
418
+ 1
417
419
)
418
420
. expect( "find should succeed" ) ,
419
421
( expectations[ 0 ] , expectations[ 1 ] )
@@ -435,7 +437,8 @@ mod test {
435
437
doc. slice( ..) ,
436
438
'\'' ,
437
439
selection. primary( ) ,
438
- FindType :: Surround ( 2 )
440
+ FindType :: Surround ,
441
+ 2
439
442
)
440
443
. expect( "find should succeed" ) ,
441
444
( expectations[ 0 ] , expectations[ 1 ] )
@@ -453,7 +456,7 @@ mod test {
453
456
454
457
assert_eq ! ( 2 , expectations. len( ) ) ;
455
458
assert_eq ! (
456
- find_nth_pairs_pos( doc. slice( ..) , '\'' , selection. primary( ) , FindType :: Next ( 3 ) )
459
+ find_nth_pairs_pos( doc. slice( ..) , '\'' , selection. primary( ) , FindType :: Next , 3 )
457
460
. expect( "find should succeed" ) ,
458
461
( expectations[ 0 ] , expectations[ 1 ] )
459
462
)
@@ -470,7 +473,7 @@ mod test {
470
473
471
474
assert_eq ! ( 2 , expectations. len( ) ) ;
472
475
assert_eq ! (
473
- find_nth_pairs_pos( doc. slice( ..) , '\'' , selection. primary( ) , FindType :: Prev ( 1 ) )
476
+ find_nth_pairs_pos( doc. slice( ..) , '\'' , selection. primary( ) , FindType :: Prev , 1 )
474
477
. expect( "find should succeed" ) ,
475
478
( expectations[ 0 ] , expectations[ 1 ] )
476
479
)
@@ -490,7 +493,8 @@ mod test {
490
493
doc. slice( ..) ,
491
494
'\'' ,
492
495
selection. primary( ) ,
493
- FindType :: Surround ( 1 )
496
+ FindType :: Surround ,
497
+ 1
494
498
) ,
495
499
Err ( Error :: CursorOnAmbiguousPair )
496
500
)
0 commit comments