Skip to content

Commit

Permalink
Fixing logging bug in wrap.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 18, 2024
1 parent f53e4be commit 3a414ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
28 changes: 11 additions & 17 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use log::Level::{Error, Info};

const WRAP: usize = 80;

// TODO add warning about long verbatim lines

pub fn needs_wrap(file: &str) -> bool {
file.lines().any(|l| l.len() > WRAP)
}
Expand Down Expand Up @@ -78,6 +80,15 @@ fn wrap_line(
}
None => {
can_wrap = false;
record_log(
logs,
Error,
pass,
filename.to_string(),
Some(linum),
Some(line.to_string()),
"Line cannot be wrapped.".to_string(),
);
}
}
}
Expand Down Expand Up @@ -125,22 +136,5 @@ pub fn wrap(
}
}

if needs_wrap(&new_file) {
for (linum, line) in new_file.lines().enumerate() {
if line_needs_wrap(line) {
// TODO check how this works with verbatim and ignore
record_log(
logs,
Error,
pass,
filename.to_string(),
Some(linum),
Some(line.to_string()),
"Line cannot be wrapped.".to_string(),
);
}
}
}

new_file
}
2 changes: 1 addition & 1 deletion tests/ignore_in.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

\begin{document}

Lines which end with the ignore keyword are not indented or wrapped % tex-fmt: skip
Lines which end with the ignore keyword are not indented or wrapped even if they are long % tex-fmt: skip

% tex-fmt: off
It is also possible to ignore blocks
Expand Down
2 changes: 1 addition & 1 deletion tests/ignore_out.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

\begin{document}

Lines which end with the ignore keyword are not indented or wrapped % tex-fmt: skip
Lines which end with the ignore keyword are not indented or wrapped even if they are long % tex-fmt: skip

% tex-fmt: off
It is also possible to ignore blocks
Expand Down

0 comments on commit 3a414ac

Please sign in to comment.