From 598fcdddc39fb9ca088e21191e35aeae51ed626e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Cassiers?= Date: Sun, 10 Jan 2016 16:25:31 +0100 Subject: [PATCH] Fix issue with windows line endings (#717). The '\r' character wasn't counted in the line length. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bae42ed44fd..3ed7c3cad8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -337,6 +337,7 @@ pub fn fmt_lines(file_map: &mut FileMap, config: &Config) -> FormatReport { for (c, b) in text.chars() { if c == '\r' { + line_len += c.len_utf8(); continue; } @@ -367,7 +368,7 @@ pub fn fmt_lines(file_map: &mut FileMap, config: &Config) -> FormatReport { last_wspace = None; } else { newline_count = 0; - line_len += 1; + line_len += c.len_utf8(); if c.is_whitespace() { if last_wspace.is_none() { last_wspace = Some(b);