Skip to content

Commit

Permalink
Fix trimming issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cdesaintguilhem committed Dec 12, 2024
1 parent ccdbc42 commit 79c03a4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,21 @@ pub fn format_file(
// removing the re-wrapped text.
let (linum_old, next_line) = queue.pop_front().unwrap(); // Doesn't panic because we can re-wrap.

let trimmed_next_line = next_line.trim_start();

// Append the re-wrapped words to the current line
line = [line.as_str(), " ", &next_line[0..rewrap_point]]
.concat();
line = [
line.as_str(),
" ",
&trimmed_next_line[0..rewrap_point],
]
.concat();

println!("Re-wrapped: {line}");

// Select the line left after re-wrapping
let next_line = next_line[rewrap_point..].trim_start();
let next_line =
trimmed_next_line[rewrap_point..].trim_start();

// Add to the queue if there text left in the next line
if !next_line.is_empty() {
Expand Down

0 comments on commit 79c03a4

Please sign in to comment.