input: Fix line number width, when line number not enable. (#916)

This commit is contained in:
Jason Lee 2025-06-03 23:40:21 +08:00 committed by GitHub
parent 2b796c94e9
commit c97cdd7b89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -331,6 +331,10 @@ impl TextElement {
line_height: Pixels,
bounds: &Bounds<Pixels>,
) -> Range<usize> {
if state.is_single_line() {
return 0..1;
}
let scroll_top = -state.scroll_handle.offset().y;
let mut visible_range = 0..state.text_wrapper.lines.len();
let mut line_top = px(0.);
@ -540,8 +544,11 @@ impl Element for TextElement {
None,
)
.unwrap();
let line_number_width =
empty_line_number.last().unwrap().width() + LINE_NUMBER_MARGIN_RIGHT;
let line_number_width = if input.mode.line_number() {
empty_line_number.last().unwrap().width() + LINE_NUMBER_MARGIN_RIGHT
} else {
px(0.)
};
let run = TextRun {
len: display_text.len(),