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:
parent
6d0ff7b335
commit
cf6d6b71a3
1 changed files with 6 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue