@@ -155,9 +155,9 @@ fn find_nth_closest_pairs_plain(
155155}
156156
157157pub enum FindType {
158- Surround ( usize ) ,
159- Next ( usize ) ,
160- Prev ( usize ) ,
158+ Surround ,
159+ Next ,
160+ Prev ,
161161}
162162
163163/// Find the position of surround pairs of `ch` which can be either a closing
@@ -168,6 +168,7 @@ pub fn find_nth_pairs_pos(
168168 ch : char ,
169169 range : Range ,
170170 find_type : FindType ,
171+ n : usize ,
171172) -> Result < ( usize , usize ) > {
172173 if text. len_chars ( ) < 2 {
173174 return Err ( Error :: PairNotFound ) ;
@@ -179,12 +180,12 @@ pub fn find_nth_pairs_pos(
179180 let ( open, close) = get_pair ( ch) ;
180181 let pos = range. cursor ( text) ;
181182 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) {
184185 Some ( next_pos) => ( next_pos + 1 , 1 ) ,
185186 None => return Err ( Error :: PairNotFound ) ,
186187 } ,
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) {
188189 Some ( next_pos) => ( next_pos - 1 , 1 ) ,
189190 None => return Err ( Error :: PairNotFound ) ,
190191 } ,
@@ -315,7 +316,7 @@ pub fn get_surround_pos(
315316 for & range in selection {
316317 let ( open_pos, close_pos) = {
317318 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) ?,
319320 None => find_nth_closest_pairs_pos ( syntax, text, range, skip) ?,
320321 } ;
321322 let range = Range :: new ( range_raw. 0 , range_raw. 1 ) ;
@@ -413,7 +414,8 @@ mod test {
413414 doc. slice( ..) ,
414415 '\'' ,
415416 selection. primary( ) ,
416- FindType :: Surround ( 1 )
417+ FindType :: Surround ,
418+ 1
417419 )
418420 . expect( "find should succeed" ) ,
419421 ( expectations[ 0 ] , expectations[ 1 ] )
@@ -435,7 +437,8 @@ mod test {
435437 doc. slice( ..) ,
436438 '\'' ,
437439 selection. primary( ) ,
438- FindType :: Surround ( 2 )
440+ FindType :: Surround ,
441+ 2
439442 )
440443 . expect( "find should succeed" ) ,
441444 ( expectations[ 0 ] , expectations[ 1 ] )
@@ -453,7 +456,7 @@ mod test {
453456
454457 assert_eq ! ( 2 , expectations. len( ) ) ;
455458 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 )
457460 . expect( "find should succeed" ) ,
458461 ( expectations[ 0 ] , expectations[ 1 ] )
459462 )
@@ -470,7 +473,7 @@ mod test {
470473
471474 assert_eq ! ( 2 , expectations. len( ) ) ;
472475 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 )
474477 . expect( "find should succeed" ) ,
475478 ( expectations[ 0 ] , expectations[ 1 ] )
476479 )
@@ -490,7 +493,8 @@ mod test {
490493 doc. slice( ..) ,
491494 '\'' ,
492495 selection. primary( ) ,
493- FindType :: Surround ( 1 )
496+ FindType :: Surround ,
497+ 1
494498 ) ,
495499 Err ( Error :: CursorOnAmbiguousPair )
496500 )
0 commit comments