Skip to content

Commit

Permalink
Cleaner indent counting
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Oct 15, 2024
1 parent 9557f93 commit a94522e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ impl Pattern {
}

/// Ensure that the indentation returns to zero at the end of the file
fn indents_return_to_zero(state: &State) -> bool {
#![allow(clippy::missing_const_for_fn)]
const fn indents_return_to_zero(state: &State) -> bool {
state.indent.actual == 0
}
8 changes: 4 additions & 4 deletions src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ fn get_diff(line: &str, pattern: &Pattern) -> i8 {
};

// indent for delimiters
diff += i8::try_from(line.chars().filter(|x| OPENS.contains(x)).count())
.unwrap();
diff -= i8::try_from(line.chars().filter(|x| CLOSES.contains(x)).count())
.unwrap();
diff += line
.chars()
.map(|x| i8::from(OPENS.contains(&x)) - i8::from(CLOSES.contains(&x)))
.sum::<i8>();

diff
}
Expand Down

0 comments on commit a94522e

Please sign in to comment.