From a7e677efa502aa05dd46efa5994b00b034e34ff0 Mon Sep 17 00:00:00 2001 From: Pratik Karki Date: Wed, 8 Apr 2026 22:08:00 +0545 Subject: [PATCH] gpui: Prevent underline and strikethrough artifacts on final glyph in text runs (#50934) Closes #50587 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - Fixed issue that showed underline and strikethrough when markdown preview screen was scaled to a smaller size Previously: image Now: image --------- Signed-off-by: Pratik Karki Co-authored-by: Smit Barmase --- crates/gpui/src/text_system/line.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/text_system/line.rs b/crates/gpui/src/text_system/line.rs index 611c979bc29f488fa18386c7b319a7310b6ce1c6..9c6ffdbe3f6fe630ea27651a09006819f0c281ce 100644 --- a/crates/gpui/src/text_system/line.rs +++ b/crates/gpui/src/text_system/line.rs @@ -385,8 +385,12 @@ fn paint_line( glyph_origin.x - underline_origin.x, underline_style, ); - underline_origin.x = origin.x; - underline_origin.y += line_height; + if glyph.index < run_end { + underline_origin.x = origin.x; + underline_origin.y += line_height; + } else { + current_underline = None; + } } if let Some((strikethrough_origin, strikethrough_style)) = current_strikethrough.as_mut() @@ -399,8 +403,12 @@ fn paint_line( glyph_origin.x - strikethrough_origin.x, strikethrough_style, ); - strikethrough_origin.x = origin.x; - strikethrough_origin.y += line_height; + if glyph.index < run_end { + strikethrough_origin.x = origin.x; + strikethrough_origin.y += line_height; + } else { + current_strikethrough = None; + } } glyph_origin.x = aligned_origin_x( @@ -618,8 +626,12 @@ fn paint_line_background( }, *background_color, )); - background_origin.x = origin.x; - background_origin.y += line_height; + if glyph.index < run_end { + background_origin.x = origin.x; + background_origin.y += line_height; + } else { + current_background = None; + } } glyph_origin.x = aligned_origin_x(