Skip to content

Commit

Permalink
actions: Prevent additional cursor move down on Cursor(Page)Down
Browse files Browse the repository at this point in the history
This is needed to not move two lines below the last visual selection when it
has end behind the new line character.
  • Loading branch information
JoeKar committed Dec 1, 2024
1 parent 5063901 commit a82bb1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/action/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,10 @@ func (h *BufPane) CursorUp() bool {
func (h *BufPane) CursorDown() bool {
selectionEndNewline := h.Cursor.HasSelection() && h.Cursor.CurSelection[1].X == 0
h.Cursor.Deselect(false)
h.MoveCursorDown(1)
if selectionEndNewline {
h.Cursor.Start()
} else {
h.MoveCursorDown(1)
}
h.Relocate()
return true
Expand Down Expand Up @@ -1739,6 +1740,9 @@ func (h *BufPane) CursorPageDown() bool {
h.Cursor.Deselect(false)
pageOverlap := int(h.Buf.Settings["pageoverlap"].(float64))
scrollAmount := h.BufView().Height - pageOverlap
if selectionEndNewline {
scrollAmount -= 1
}
h.MoveCursorDown(scrollAmount)
if h.Cursor.Num == 0 {
h.ScrollDown(scrollAmount)
Expand Down

0 comments on commit a82bb1f

Please sign in to comment.