Skip to content

Commit

Permalink
Flush unformated text if fmt: off is active til the end of the file
Browse files Browse the repository at this point in the history
  • Loading branch information
sthiele committed Oct 3, 2022
1 parent 998ba0d commit cc87639
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use anyhow::Result;
use log::{debug, warn};
use std::io::Write;

const SOFT_FLUSH_LIMIT :usize = 60;

const SOFT_FLUSH_LIMIT: usize = 60;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -221,6 +220,12 @@ pub fn format_program(
match node.kind() {
"source_file" => {
formatter.finish_program()?;
if skip_fmt {
let unformated_text =
std::str::from_utf8(&source_code[start_unformatted..node.end_byte()])
.unwrap();
write!(formatter.out, "{}", unformated_text)?;
}
}
"statement" => short_cut = false,
_ => {}
Expand Down

0 comments on commit cc87639

Please sign in to comment.