editor: Add delay for selection drag to prevent accidental drag over attempt for new selection (#32586)

- Add `300ms` delay for it to consider it as selection drag instead of
an attempt to make a new selection.
- Add cursor icon while dragging the selection.

This is same as what chromium does:
https://chromium.googlesource.com/chromium/blink/+/master/Source/core/input/EventHandler.cpp#142

Release Notes:

- Fixed issue where you accidentally end up dragging the selection where
intent was to make a new one instead. To drag selection now, you need to
hold just a little longer before dragging.
This commit is contained in:
Smit Barmase 2025-06-12 06:07:20 +05:30 committed by GitHub
parent 04223f304b
commit 13ee78c0b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 57 additions and 16 deletions

View file

@ -912,6 +912,7 @@ enum SelectionDragState {
ReadyToDrag {
selection: Selection<Anchor>,
click_position: gpui::Point<Pixels>,
mouse_down_time: Instant,
},
/// State when the mouse is dragging the selection in the editor.
Dragging {