Fix Deselect() after mouse selection (#3268)

Ensure that the selection start is always before the selection end,
regardless of the direction of a mouse selection, to make
h.Cursor.Deselect() handle its `start` argument correctly.

This makes the cursor behavior after mouse selections consistent with
the cursor behavior after keyboard selections.

Fixes #3055
This commit is contained in:
Dmytro Maluka 2024-04-25 21:58:40 +02:00 committed by GitHub
parent 147943837d
commit 3f810c24d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -113,7 +113,7 @@ func (h *BufPane) MouseDrag(e *tcell.EventMouse) bool {
} else if h.doubleClick { } else if h.doubleClick {
h.Cursor.AddWordToSelection() h.Cursor.AddWordToSelection()
} else { } else {
h.Cursor.SetSelectionEnd(h.Cursor.Loc) h.Cursor.SelectTo(h.Cursor.Loc)
} }
h.Cursor.StoreVisualX() h.Cursor.StoreVisualX()