Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Avoid gutter resizes on line number increase/decrease
Kirill Bulatovbf8e57098d0a
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 06faf3265eb..ec1d3085153 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -1790,8 +1790,10 @@ impl EditorElement {let descent = cx.text_system().descent(font_id, font_size);let gutter_padding_factor = 3.5;+ // Avoid flicker-like gutter resizes when the line number gains another digit and only resize the gutter on files with N*10^5 lines.+ let min_width_for_number_on_gutter = em_width * 4.0;gutter_padding = (em_width * gutter_padding_factor).round();- gutter_width = self.max_line_number_width(&snapshot, cx) + gutter_padding * 2.0;+ gutter_width = self.max_line_number_width(&snapshot, cx).max(min_width_for_number_on_gutter) + gutter_padding * 2.0;gutter_margin = -descent;} else {gutter_padding = Pixels::ZERO;@@ -3843,7 +3845,9 @@ fn compute_auto_height_layout(let descent = cx.text_system().descent(font_id, font_size);let gutter_padding_factor = 3.5;let gutter_padding = (em_width * gutter_padding_factor).round();- gutter_width = max_line_number_width + gutter_padding * 2.0;+ let min_width_for_number_on_gutter = em_width * 4.0;+ gutter_width =+ max_line_number_width.max(min_width_for_number_on_gutter) + gutter_padding * 2.0;gutter_margin = -descent;} else {gutter_width = Pixels::ZERO;