Skip to content

Commit

Permalink
Fix issue with windows line endings (#717).
Browse files Browse the repository at this point in the history
The '\r' character wasn't counted in the line length.
  • Loading branch information
cassiersg committed Jan 10, 2016
1 parent 66abad9 commit 598fcdd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 598fcdd

Please sign in to comment.