Skip to content

Commit

Permalink
Trim newlines on text inserted that does not need additional spans op…
Browse files Browse the repository at this point in the history
…ening
  • Loading branch information
w4 committed May 21, 2024
1 parent 27cfc0a commit 9245909
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,15 @@ fn format_file_inner(
// of open spans, so we can open and close them for each line
for &(i, ref op) in &ops {
if i > cur_index {
let prefix = &line[cur_index..i];
let prefix = if code_tag {
prefix.trim_end_matches('\n')
} else {
prefix
};
write!(out, "{}", Escape(prefix))?;

span_empty = false;
write!(out, "{}", Escape(&line[cur_index..i]))?;
cur_index = i;
}

Expand Down

0 comments on commit 9245909

Please sign in to comment.