From 9245909d716bdfc3c54c35839f4009df7e943f9c Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 21 May 2024 12:08:51 +0200 Subject: [PATCH] Trim newlines on text inserted that does not need additional spans opening --- src/git.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/git.rs b/src/git.rs index 6eec6cf..fe0dda4 100644 --- a/src/git.rs +++ a/src/git.rs @@ -729,8 +729,15 @@ // 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; } -- rgit 0.1.3