Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix `closest_index_for_x` to get correct offset when only 1 char (#23603)
Jason Lee3eba831de8a4
diff --git a/crates/gpui/src/text_system/line_layout.rs b/crates/gpui/src/text_system/line_layout.rsindex a78c07fa26b..f2379feded5 100644--- a/crates/gpui/src/text_system/line_layout.rs+++ b/crates/gpui/src/text_system/line_layout.rs@@ -90,6 +90,14 @@ impl LineLayout {}}+ if self.len == 1 {+ if x > self.width / 2. {+ return 1;+ } else {+ return 0;+ }+ }+self.len}