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 22, 2025
1 parent f5debdf commit 5a8d691
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/action/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,17 @@ 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) {
newEnd := end.Move(deltaX, h.Buf)
h.Cursor.SetSelectionEnd(newEnd)
h.Cursor.GotoLoc(newEnd)
} 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 5a8d691

Please sign in to comment.