From 55e97596d3a0388aeecf95a98ee01e96b466cce7 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 7 May 2020 19:39:17 -0400 Subject: [PATCH] Fix movelinesup when selection is not complete --- internal/action/actions.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index 1147d6db..d5571d09 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1027,15 +1027,26 @@ func (h *BufPane) MoveLinesUp() bool { } start := h.Cursor.CurSelection[0].Y end := h.Cursor.CurSelection[1].Y + sel := 1 if start > end { end, start = start, end + sel = 0 + } + + compensate := false + if h.Cursor.CurSelection[sel].X != 0 { + end++ + } else { + compensate = true } h.Buf.MoveLinesUp( start, end, ) - h.Cursor.CurSelection[1].Y -= 1 + if compensate { + h.Cursor.CurSelection[sel].Y -= 1 + } } else { if h.Cursor.Loc.Y == 0 { InfoBar.Message("Cannot move further up") @@ -1060,8 +1071,14 @@ func (h *BufPane) MoveLinesDown() bool { } start := h.Cursor.CurSelection[0].Y end := h.Cursor.CurSelection[1].Y + sel := 1 if start > end { end, start = start, end + sel = 0 + } + + if h.Cursor.CurSelection[sel].X != 0 { + end++ } h.Buf.MoveLinesDown(