actions: Prevent additional cursor move down on Cursor(Page)Down

This is needed to not move two lines below the last visual selection when it
has end behind the new line character.
This commit is contained in:
Jöran Karl 2024-11-30 16:51:13 +01:00
parent 50639015d7
commit 2c4754d484

View File

@ -256,9 +256,10 @@ func (h *BufPane) CursorUp() bool {
func (h *BufPane) CursorDown() bool { func (h *BufPane) CursorDown() bool {
selectionEndNewline := h.Cursor.HasSelection() && h.Cursor.CurSelection[1].X == 0 selectionEndNewline := h.Cursor.HasSelection() && h.Cursor.CurSelection[1].X == 0
h.Cursor.Deselect(false) h.Cursor.Deselect(false)
h.MoveCursorDown(1)
if selectionEndNewline { if selectionEndNewline {
h.Cursor.Start() h.Cursor.Start()
} else {
h.MoveCursorDown(1)
} }
h.Relocate() h.Relocate()
return true return true
@ -1739,6 +1740,9 @@ func (h *BufPane) CursorPageDown() bool {
h.Cursor.Deselect(false) h.Cursor.Deselect(false)
pageOverlap := int(h.Buf.Settings["pageoverlap"].(float64)) pageOverlap := int(h.Buf.Settings["pageoverlap"].(float64))
scrollAmount := h.BufView().Height - pageOverlap scrollAmount := h.BufView().Height - pageOverlap
if selectionEndNewline {
scrollAmount--
}
h.MoveCursorDown(scrollAmount) h.MoveCursorDown(scrollAmount)
if h.Cursor.Num == 0 { if h.Cursor.Num == 0 {
h.ScrollDown(scrollAmount) h.ScrollDown(scrollAmount)