Change how the width of the gutter is calculated considering propotional fonts. #21860
Open
1 task done
Labels
design papercut
Small visual defect
editor
Feedback for code editing, formatting, editor iterations, etc
good first issue
Issue suitable for first-time contributors
Check for existing issues
Describe the bug / provide steps to reproduce it
Pull request #4135 sets that there are always 4 ems of space reserved for the line number to prevent changing the width much. The idea is reasonable, but em is defined as the width of ‘m’. In proportional fonts, ‘m’ is usually much wider than numerals, so the gutter is too wide. That can be seen in this comment.
The same em is used to calculate padding, so the gutter also has too much padding.
Reproduction
"buffer_font_family": "Noto Sans"
Solution
I suggest that the width of the numeral ‘0’ would be used as the width of a digit in the gutter. The width of digits usually does not vary much, and, if so, usually just because ‘1’ is narrower. So there is practically no risk of not enough space in the gutter for 4 digits.
It seems that it would be solved by redefining the variables
em_width
andem_advance
in the appropriate functions. When #4135 was merged, the appropriate functions werecompute_layout
andcompute_auto_height_layout
in crates/editor/src/element.rs. But the file has changed, so I don't know which are the appropriate functions now.The variables would be redefined so:
The names no longer reflect their function, so they should be changed to something more suitable.
Environment
Zed: v0.164.2 (Zed)
OS: Linux X11 arch unknown
Memory: 15.6 GiB
Architecture: x86_64
GPU: AMD Radeon RX 580 2048SP (RADV POLARIS10) || radv || Mesa 24.3.1-arch1.1
If applicable, add mockups / screenshots to help explain present your vision of the feature
The text was updated successfully, but these errors were encountered: