mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 15:44:31 +03:00
Avoid gutter resizes on line number increase/decrease
Reserves 4 characters for the line number in the gutter to avoid editor bounds jumping when editing small files like commit messages.
This commit is contained in:
parent
578bcecdb6
commit
bf8e57098d
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user