Skip to content

Commit e6ed161

Browse files
committed
SpawnMultiCursorUp/Down: revert honoring softwrap
Commit 9fdea82 ("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 zyedidia#3499
1 parent 134cd99 commit e6ed161

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

internal/action/actions.go

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,37 +2060,20 @@ func (h *BufPane) SpawnCursorAtLoc(loc buffer.Loc) *buffer.Cursor {
20602060
// SpawnMultiCursorUpN is not an action
20612061
func (h *BufPane) SpawnMultiCursorUpN(n int) bool {
20622062
lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1)
2063-
var c *buffer.Cursor
2064-
if !h.Buf.Settings["softwrap"].(bool) {
2065-
if n > 0 && lastC.Y == 0 {
2066-
return false
2067-
}
2068-
if n < 0 && lastC.Y+1 == h.Buf.LinesNum() {
2069-
return false
2070-
}
2071-
2072-
h.Buf.DeselectCursors()
2073-
2074-
c = buffer.NewCursor(h.Buf, buffer.Loc{lastC.X, lastC.Y - n})
2075-
c.LastVisualX = lastC.LastVisualX
2076-
c.LastWrappedVisualX = lastC.LastWrappedVisualX
2077-
c.X = c.GetCharPosInLine(h.Buf.LineBytes(c.Y), c.LastVisualX)
2078-
c.Relocate()
2079-
} else {
2080-
vloc := h.VLocFromLoc(lastC.Loc)
2081-
sloc := h.Scroll(vloc.SLoc, -n)
2082-
if sloc == vloc.SLoc {
2083-
return false
2084-
}
2063+
if n > 0 && lastC.Y == 0 {
2064+
return false
2065+
}
2066+
if n < 0 && lastC.Y+1 == h.Buf.LinesNum() {
2067+
return false
2068+
}
20852069

2086-
h.Buf.DeselectCursors()
2070+
h.Buf.DeselectCursors()
20872071

2088-
vloc.SLoc = sloc
2089-
vloc.VisualX = lastC.LastWrappedVisualX
2090-
c = buffer.NewCursor(h.Buf, h.LocFromVLoc(vloc))
2091-
c.LastVisualX = lastC.LastVisualX
2092-
c.LastWrappedVisualX = lastC.LastWrappedVisualX
2093-
}
2072+
c := buffer.NewCursor(h.Buf, buffer.Loc{lastC.X, lastC.Y - n})
2073+
c.LastVisualX = lastC.LastVisualX
2074+
c.LastWrappedVisualX = lastC.LastWrappedVisualX
2075+
c.X = c.GetCharPosInLine(h.Buf.LineBytes(c.Y), c.LastVisualX)
2076+
c.Relocate()
20942077

20952078
h.Buf.AddCursor(c)
20962079
h.Buf.SetCurCursor(h.Buf.NumCursors() - 1)

0 commit comments

Comments
 (0)