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 <huacnlee@gmail.com>
This commit is contained in:
Andreas Johansson 2025-11-14 02:56:10 +01:00 committed by GitHub
parent 6d0ff7b335
commit cf6d6b71a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,