From e6ed161ca48d7b5f2f8f1f4000e6de79729a4a13 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sun, 13 Oct 2024 23:20:57 +0200 Subject: [PATCH] SpawnMultiCursorUp/Down: revert honoring softwrap Commit 9fdea8254250 ("Fix various issues with `SpawnMultiCursor{Up,Down}`") changed SpawnMultiCursorUp/Down actions to honor softwrap, i.e. spawn cursor in the next visual line within a wrapped line, which may not be the next logical line in a buffer. That was done for "consistency" with cursor movement actions CursorUp/Down etc. But it seems there are no actual use cases for that, whereas at least some users prefer spawning multicursor in the next logical line regardless of the softwrap setting. So restore the old behavior. Fixes #3499 --- internal/action/actions.go | 43 ++++++++++++-------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index 2ea8f472..54982957 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -2060,37 +2060,20 @@ func (h *BufPane) SpawnCursorAtLoc(loc buffer.Loc) *buffer.Cursor { // SpawnMultiCursorUpN is not an action func (h *BufPane) SpawnMultiCursorUpN(n int) bool { lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1) - var c *buffer.Cursor - if !h.Buf.Settings["softwrap"].(bool) { - if n > 0 && lastC.Y == 0 { - return false - } - if n < 0 && lastC.Y+1 == h.Buf.LinesNum() { - return false - } - - h.Buf.DeselectCursors() - - c = buffer.NewCursor(h.Buf, buffer.Loc{lastC.X, lastC.Y - n}) - c.LastVisualX = lastC.LastVisualX - c.LastWrappedVisualX = lastC.LastWrappedVisualX - c.X = c.GetCharPosInLine(h.Buf.LineBytes(c.Y), c.LastVisualX) - c.Relocate() - } else { - vloc := h.VLocFromLoc(lastC.Loc) - sloc := h.Scroll(vloc.SLoc, -n) - if sloc == vloc.SLoc { - return false - } - - h.Buf.DeselectCursors() - - vloc.SLoc = sloc - vloc.VisualX = lastC.LastWrappedVisualX - c = buffer.NewCursor(h.Buf, h.LocFromVLoc(vloc)) - c.LastVisualX = lastC.LastVisualX - c.LastWrappedVisualX = lastC.LastWrappedVisualX + if n > 0 && lastC.Y == 0 { + return false } + if n < 0 && lastC.Y+1 == h.Buf.LinesNum() { + return false + } + + h.Buf.DeselectCursors() + + c := buffer.NewCursor(h.Buf, buffer.Loc{lastC.X, lastC.Y - n}) + c.LastVisualX = lastC.LastVisualX + c.LastWrappedVisualX = lastC.LastWrappedVisualX + c.X = c.GetCharPosInLine(h.Buf.LineBytes(c.Y), c.LastVisualX) + c.Relocate() h.Buf.AddCursor(c) h.Buf.SetCurCursor(h.Buf.NumCursors() - 1)