mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 10:42:08 +00:00
Fix closest_index_for_x
to get correct offset when only 1 char (#23603)
Release Notes: - N/A ---------- This bug can easy to replay by `input` example, just enter 1 char and click on the middle of the char, we can't move cursor to 0, it is always be 1. ```bash cargo run -p gpui --example input ``` ## Before https://github.com/user-attachments/assets/3239dd47-278e-4311-9757-5165d1ccd796 ## After https://github.com/user-attachments/assets/4e2c1500-0142-4e28-bf34-7ef1f4929925
This commit is contained in:
parent
02503cf3be
commit
3eba831de8
1 changed files with 8 additions and 0 deletions
|
@ -90,6 +90,14 @@ impl LineLayout {
|
|||
}
|
||||
}
|
||||
|
||||
if self.len == 1 {
|
||||
if x > self.width / 2. {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
self.len
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue