From cf6d6b71a3356b7cd69a0590f222a80f914de826 Mon Sep 17 00:00:00 2001 From: Andreas Johansson Date: Fri, 14 Nov 2025 02:56:10 +0100 Subject: [PATCH] input: Fix x offset resetting for single line inputs (#1591) Fixes #1589 Before: https://github.com/user-attachments/assets/ae1dd1c4-de97-4336-94ab-e545a1e97047 After: https://github.com/user-attachments/assets/62b5cf08-0782-426e-b2ee-dc018f140149 --------- Co-authored-by: Jason Lee --- crates/ui/src/input/element.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/ui/src/input/element.rs b/crates/ui/src/input/element.rs index 91bfbca4..ab716d77 100644 --- a/crates/ui/src/input/element.rs +++ b/crates/ui/src/input/element.rs @@ -952,16 +952,18 @@ impl Element for TextElement { ); let mut longest_line_width = wrap_width.unwrap_or(px(0.)); - if state.mode.is_multi_line() && !state.soft_wrap && lines.len() > 1 { + // 1. Single line + // 2. Multi-line with soft wrap disabled. + if state.mode.is_single_line() || !state.soft_wrap { let longest_row = state.text_wrapper.longest_row.row; - let longtest_line: SharedString = state.text.slice_line(longest_row).to_string().into(); + let longest_line: SharedString = state.text.slice_line(longest_row).to_string().into(); longest_line_width = window .text_system() .shape_line( - longtest_line.clone(), + longest_line.clone(), font_size, &[TextRun { - len: longtest_line.len(), + len: longest_line.len(), font: style.font(), color: gpui::black(), background_color: None,