File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,17 @@ where
3838}
3939
4040pub fn until_next_unindented ( input : & str , at_least_until : usize , fallback_len : usize ) -> & str {
41- match regex:: Regex :: new ( "\n [A-Za-z0-9]" )
42- . ok ( )
43- . and_then ( |needle| needle. find ( & input[ at_least_until..] ) )
44- {
45- Some ( m) => & input[ ..( m. start ( ) + at_least_until) ] ,
46- _ => input[ ..input. len ( ) . min ( fallback_len) ] . trim ( ) ,
41+ let mut prev_was_newline = false ;
42+ for ( idx, ch) in input[ at_least_until..] . char_indices ( ) {
43+ if prev_was_newline && ch. is_ascii_alphanumeric ( ) {
44+ // Found "\n[A-Za-z0-9]" pattern, return up to the newline
45+ return & input[ ..( idx - 1 + at_least_until) ] ;
46+ }
47+ prev_was_newline = ch == '\n' ;
4748 }
49+
50+ // No match found, use fallback
51+ input[ ..input. len ( ) . min ( fallback_len) ] . trim ( )
4852}
4953
5054pub fn hex_to_bools ( c : char ) -> [ bool ; 4 ] {
You can’t perform that action at this time.
0 commit comments