Skip to content

Commit

Permalink
adjust selection after replaceall
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias314 committed Jan 21, 2025
1 parent f5debdf commit 6b5805c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/action/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,15 @@ func (h *BufPane) ReplaceCmd(args []string) {
searchLoc = start // otherwise me might start at the end
}
if all {
nreplaced, _ = h.Buf.ReplaceRegex(start, end, regex, replace, !noRegex)
var deltaX int
nreplaced, deltaX = h.Buf.ReplaceRegex(start, end, regex, replace, !noRegex)
if selection {
if start.LessEqual(end) {
h.Cursor.SetSelectionEnd(end.Move(deltaX, h.Buf))
} else {
h.Cursor.SetSelectionStart(start.Move(deltaX, h.Buf))
}
}
} else {
inRange := func(l buffer.Loc) bool {
return l.GreaterEqual(start) && l.LessEqual(end)
Expand Down

0 comments on commit 6b5805c

Please sign in to comment.