Skip to content

Commit

Permalink
Reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Oct 16, 2024
1 parent 8977902 commit 2311d12
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ fn get_diff(line: &str, pattern: &Pattern) -> i8 {
/// Calculate dedentation for the current line
fn get_back(line: &str, pattern: &Pattern) -> i8 {
let mut back: i8 = 0;
let mut cumul: i8 = 0;

// Dedent delimiters
// Check first whether there are any closing delimiters
if CLOSES.iter().any(|c| line.contains(*c)) {
for c in line.chars() {
cumul -= i8::from(OPENS.contains(&c));
cumul += i8::from(CLOSES.contains(&c));
back = max(cumul, back);
}
}

// other environments get single indents
if pattern.contains_env_end && line.contains(ENV_END) {
Expand All @@ -93,6 +82,17 @@ fn get_back(line: &str, pattern: &Pattern) -> i8 {
back += 1;
};

// Dedent delimiters
// Check first whether there are any closing delimiters
if CLOSES.iter().any(|c| line.contains(*c)) {
let mut cumul: i8 = back;
for c in line.chars() {
cumul -= i8::from(OPENS.contains(&c));
cumul += i8::from(CLOSES.contains(&c));
back = max(cumul, back);
}
}

// deindent items to make the rest of item environment appear indented
if pattern.contains_item && line.contains(ITEM) {
back += 1;
Expand Down

0 comments on commit 2311d12

Please sign in to comment.