@@ -105,7 +105,7 @@ pub fn rewrite_string<'a>(
105
105
// All the input starting at cur_start fits on the current line
106
106
if graphemes. len ( ) - cur_start <= cur_max_chars {
107
107
for ( i, grapheme) in graphemes[ cur_start..] . iter ( ) . enumerate ( ) {
108
- if is_line_feed ( grapheme) {
108
+ if is_new_line ( grapheme) {
109
109
// take care of blank lines
110
110
result = trim_end_but_line_feed ( fmt. trim_end , result) ;
111
111
result. push_str ( "\n " ) ;
@@ -223,7 +223,7 @@ enum SnippetState {
223
223
}
224
224
225
225
fn not_whitespace_except_line_feed ( g : & str ) -> bool {
226
- is_line_feed ( g) || !is_whitespace ( g)
226
+ is_new_line ( g) || !is_whitespace ( g)
227
227
}
228
228
229
229
/// Break the input string at a boundary character around the offset `max_chars`. A boundary
@@ -240,7 +240,7 @@ fn break_string(max_chars: usize, trim_end: bool, line_end: &str, input: &[&str]
240
240
// line. If there is one, then text after it could be rewritten in a way that the available
241
241
// space is fully used.
242
242
for ( i, grapheme) in input[ 0 ..=index] . iter ( ) . enumerate ( ) {
243
- if is_line_feed ( grapheme) {
243
+ if is_new_line ( grapheme) {
244
244
if i <= index_minus_ws {
245
245
let mut line = & input[ 0 ..i] . concat ( ) [ ..] ;
246
246
if trim_end {
@@ -254,7 +254,7 @@ fn break_string(max_chars: usize, trim_end: bool, line_end: &str, input: &[&str]
254
254
255
255
let mut index_plus_ws = index;
256
256
for ( i, grapheme) in input[ index + 1 ..] . iter ( ) . enumerate ( ) {
257
- if !trim_end && is_line_feed ( grapheme) {
257
+ if !trim_end && is_new_line ( grapheme) {
258
258
return SnippetState :: EndWithLineFeed (
259
259
input[ 0 ..=index + 1 + i] . concat ( ) ,
260
260
index + 2 + i,
@@ -325,8 +325,9 @@ fn break_string(max_chars: usize, trim_end: bool, line_end: &str, input: &[&str]
325
325
}
326
326
}
327
327
328
- fn is_line_feed ( grapheme : & str ) -> bool {
329
- grapheme. as_bytes ( ) [ 0 ] == b'\n'
328
+ fn is_new_line ( grapheme : & str ) -> bool {
329
+ let bytes = grapheme. as_bytes ( ) ;
330
+ bytes. starts_with ( b"\n " ) || bytes. starts_with ( b"\r \n " )
330
331
}
331
332
332
333
fn is_whitespace ( grapheme : & str ) -> bool {
0 commit comments