longbridgeapp / gpui-component

UI components write in GPUI.
Apache License 2.0
150 stars 20 forks source link

input: Update Input selection behavior to like OS input. #247

Closed huacnlee closed 1 month ago

huacnlee commented 1 month ago

Revert old implementation

Before

https://github.com/user-attachments/assets/52ce2e3a-3e1d-4ba2-af42-76b1df987404

After

https://github.com/user-attachments/assets/9aa8cfe1-5928-4d20-b534-806140c7ee59

The Input in the Browser

https://github.com/user-attachments/assets/c913248e-b1dc-46d6-a517-e1231e606171

huacnlee commented 1 month ago

https://github.com/user-attachments/assets/42fffadd-41a5-419b-bd78-1f65eeba6c02

@ConradIrwin To check out these details, this changes is unlike your was done https://github.com/zed-industries/zed/pull/14350. When this mouse is on the cursor left, then select to left, otherwise select to right.

And this also listen the mouse event on the window not on Input to continue handle event mouse is moved out the Input bounds.

huacnlee commented 1 month ago

Diff Zed and Chrome

https://github.com/user-attachments/assets/d20a225b-705e-411e-9433-1714a13ef484

huacnlee commented 1 month ago

And why we need to do like this:

When we fast move mouse to left, we may end mouse at the Input top side or bottom size, they may both happen. Because we can not move in the horizontal line.

So we need to continue the user move direction to select text. If we move to left, that means we want to select to left, otherwise we want to select to right.