Skip to content

Commit

Permalink
Split condition tree into distinct blocks with continue
Browse files Browse the repository at this point in the history
  • Loading branch information
cdesaintguilhem committed Oct 13, 2024
1 parent e974225 commit 1b90f21
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,24 @@ pub fn format_file(
if env_lines.is_some() {
queue.push((linum_old, env_lines.clone().unwrap().1));
queue.push((linum_old, env_lines.clone().unwrap().0));
} else {
state = temp_state;
new_text.push_str(&line);
new_text.push_str(LINE_END);
state.linum_new += 1;
};
} else if needs_wrap(&line, &temp_state, args) {
continue;
}
}

if needs_wrap(&line, &temp_state, args) {
let wrapped_lines =
apply_wrap(&line, &temp_state, file, args, logs);
if wrapped_lines.is_some() {
queue.push((linum_old, wrapped_lines.clone().unwrap().1));
queue.push((linum_old, wrapped_lines.clone().unwrap().0));
} else {
state = temp_state;
new_text.push_str(&line);
new_text.push_str(LINE_END);
state.linum_new += 1;
};
} else {
state = temp_state;
new_text.push_str(&line);
new_text.push_str(LINE_END);
state.linum_new += 1;
continue;
}
}

state = temp_state;
new_text.push_str(&line);
new_text.push_str(LINE_END);
state.linum_new += 1;
} else if let Some((linum_old, line)) = old_lines.next() {
queue.push((linum_old, line.to_string()));
} else {
Expand Down

0 comments on commit 1b90f21

Please sign in to comment.