Skip to content

Commit 6b5805c

Browse files
committed
adjust selection after replaceall
1 parent f5debdf commit 6b5805c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

internal/action/command.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,15 @@ func (h *BufPane) ReplaceCmd(args []string) {
958958
searchLoc = start // otherwise me might start at the end
959959
}
960960
if all {
961-
nreplaced, _ = h.Buf.ReplaceRegex(start, end, regex, replace, !noRegex)
961+
var deltaX int
962+
nreplaced, deltaX = h.Buf.ReplaceRegex(start, end, regex, replace, !noRegex)
963+
if selection {
964+
if start.LessEqual(end) {
965+
h.Cursor.SetSelectionEnd(end.Move(deltaX, h.Buf))
966+
} else {
967+
h.Cursor.SetSelectionStart(start.Move(deltaX, h.Buf))
968+
}
969+
}
962970
} else {
963971
inRange := func(l buffer.Loc) bool {
964972
return l.GreaterEqual(start) && l.LessEqual(end)

0 commit comments

Comments
 (0)