Skip to content

Commit

Permalink
Plan line formatting logic steps
Browse files Browse the repository at this point in the history
  • Loading branch information
cdesaintguilhem committed Oct 13, 2024
1 parent 4bf802a commit e974225
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ pub fn format_file(
let mut queue: Vec<(usize, String)> = vec![];
let mut new_text = String::with_capacity(2 * old_tex.len());

// Select the character used for indentation
// Select the character used for indentation.
let indent_char = if args.usetabs { "\t" } else { " " };

loop {
if let Some((linum_old, mut line)) = queue.pop() {
// Read the patterns present on this line.
let pattern = Pattern::new(&line);

let temp_state: State;

// Apply indent based on the current state and the patterns in the line.
(line, temp_state) = apply_indent(
&line,
linum_old,
Expand All @@ -47,6 +51,18 @@ pub fn format_file(
&pattern,
indent_char,
);

// Split the line based on:
// - environment commands, and
// - sectioning commands,
// and add the split to the queue.

// Wrap the line after indenting, and add the wrap to the queue.

// TODO: implement debug checks that the indent and the line length are correct.

// Add line to new text

if needs_env_new_line(&line, &temp_state, &pattern) {
let env_lines =
put_env_new_line(&line, &temp_state, file, args, logs);
Expand Down

0 comments on commit e974225

Please sign in to comment.