Skip to content

Commit

Permalink
Check indentation return to 0 on state instead of new_text
Browse files Browse the repository at this point in the history
  • Loading branch information
cdesaintguilhem committed Oct 13, 2024
1 parent 1b90f21 commit c49a08c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ pub fn format_file(
}
}

if !indents_return_to_zero(&new_text) {
if !indents_return_to_zero(&state) {
println!("{state:?}");
record_file_log(logs, Warn, file, "Indent does not return to zero.");
}

Expand Down Expand Up @@ -166,6 +167,6 @@ impl Pattern {
}

/// Ensure that the indentation returns to zero at the end of the file
fn indents_return_to_zero(text: &str) -> bool {
!text.lines().last().unwrap_or_default().starts_with(' ')
fn indents_return_to_zero(state: &State) -> bool {
state.indent.actual == 0
}

0 comments on commit c49a08c

Please sign in to comment.