@@ -24,7 +24,10 @@ use tempfile::TempDir;
2424#[ derive( Debug , Clone ) ]
2525enum BufferOp {
2626 /// Insert bytes at a specific offset
27- Insert { offset_percent : u8 , content : Vec < u8 > } ,
27+ Insert {
28+ offset_percent : u8 ,
29+ content : Vec < u8 > ,
30+ } ,
2831 /// Delete bytes at a specific offset
2932 Delete { offset_percent : u8 , len_percent : u8 } ,
3033 /// Insert at the very start
@@ -66,7 +69,9 @@ impl BufferOp {
6669 let len = if max_len == 0 {
6770 0
6871 } else {
69- ( ( max_len * ( * len_percent as usize ) ) / 255 ) . max ( 1 ) . min ( max_len)
72+ ( ( max_len * ( * len_percent as usize ) ) / 255 )
73+ . max ( 1 )
74+ . min ( max_len)
7075 } ;
7176 if len > 0 && offset < total {
7277 buffer. delete_bytes ( offset, len) ;
@@ -127,7 +132,9 @@ impl BufferOp {
127132 let len = if max_len == 0 {
128133 0
129134 } else {
130- ( ( max_len * ( * len_percent as usize ) ) / 255 ) . max ( 1 ) . min ( max_len)
135+ ( ( max_len * ( * len_percent as usize ) ) / 255 )
136+ . max ( 1 )
137+ . min ( max_len)
131138 } ;
132139 if len > 0 && offset < total {
133140 shadow. drain ( offset..offset + len) ;
@@ -1004,20 +1011,18 @@ fn content_with_crlf_strategy(max_lines: usize) -> impl Strategy<Value = Vec<u8>
10041011}
10051012
10061013fn content_with_lf_strategy ( max_lines : usize ) -> impl Strategy < Value = Vec < u8 > > {
1007- prop:: collection:: vec (
1008- prop:: collection:: vec ( 32u8 ..127u8 , 5 ..30 ) ,
1009- 1 ..=max_lines,
1010- )
1011- . prop_map ( |lines| {
1012- let mut result = Vec :: new ( ) ;
1013- for ( i, line) in lines. iter ( ) . enumerate ( ) {
1014- result. extend ( line) ;
1015- if i < lines. len ( ) - 1 {
1016- result. push ( b'\n' ) ; // LF line endings
1014+ prop:: collection:: vec ( prop:: collection:: vec ( 32u8 ..127u8 , 5 ..30 ) , 1 ..=max_lines) . prop_map (
1015+ |lines| {
1016+ let mut result = Vec :: new ( ) ;
1017+ for ( i, line) in lines. iter ( ) . enumerate ( ) {
1018+ result. extend ( line) ;
1019+ if i < lines. len ( ) - 1 {
1020+ result. push ( b'\n' ) ; // LF line endings
1021+ }
10171022 }
1018- }
1019- result
1020- } )
1023+ result
1024+ } ,
1025+ )
10211026}
10221027
10231028fn content_with_mixed_endings_strategy ( max_lines : usize ) -> impl Strategy < Value = Vec < u8 > > {
@@ -1204,8 +1209,7 @@ fn test_crlf_preserved_after_edit() {
12041209
12051210 // Should have CRLF throughout
12061211 assert_eq ! (
1207- saved,
1208- b"line1\r \n inserted\r \n line2\r \n line3\r \n " ,
1212+ saved, b"line1\r \n inserted\r \n line2\r \n line3\r \n " ,
12091213 "CRLF should be preserved"
12101214 ) ;
12111215}
0 commit comments