From f227c3284de3792f39ad42fca559529403ea0783 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 24 Nov 2023 17:53:48 +0100 Subject: [PATCH] Consume newline from run if it spans it --- crates/gpui2/src/text_system.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/gpui2/src/text_system.rs b/crates/gpui2/src/text_system.rs index 76e21e5f7339cf2ac69e8caf3773e3456a56f3f8..440789dd472b35c02e1bbf3c2605e7b4c8ae3be3 100644 --- a/crates/gpui2/src/text_system.rs +++ b/crates/gpui2/src/text_system.rs @@ -290,7 +290,15 @@ impl TextSystem { text: SharedString::from(line_text), }); - line_start = line_end + 1; // Skip `\n` character. + // Skip `\n` character. + line_start = line_end + 1; + if let Some(run) = runs.peek_mut() { + run.len = run.len.saturating_sub(1); + if run.len == 0 { + runs.next(); + } + } + font_runs.clear(); }