Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix off-by-one highlighting in hover tooltip

Conrad Irwin98d514f5bf2c
diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs
index f311f20ae6d..a4bc1c5cdeb 100644
--- a/crates/editor/src/hover_popover.rs
+++ b/crates/editor/src/hover_popover.rs
@@ -394,6 +394,27 @@ async fn parse_blocks(
}
}
+ let leading_space = text.chars().take_while(|c| c.is_whitespace()).count();
+ if leading_space > 0 {
+ highlights = highlights
+ .into_iter()
+ .map(|(range, style)| {
+ (
+ range.start.saturating_sub(leading_space)
+ ..range.end.saturating_sub(leading_space),
+ style,
+ )
+ })
+ .collect();
+ region_ranges = region_ranges
+ .into_iter()
+ .map(|range| {
+ range.start.saturating_sub(leading_space)
+ ..range.end.saturating_sub(leading_space),
+ })
+ .collect();
+ }
+
ParsedMarkdown {
text: text.trim().to_string(),
highlights,