This commit is contained in:
matthias314 2025-05-27 11:10:27 +02:00 committed by GitHub
commit f43864638e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -969,7 +969,17 @@ func (h *BufPane) ReplaceCmd(args []string) {
searchLoc = start // otherwise me might start at the end searchLoc = start // otherwise me might start at the end
} }
if all { 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 { } else {
inRange := func(l buffer.Loc) bool { inRange := func(l buffer.Loc) bool {
return l.GreaterEqual(start) && l.LessEqual(end) return l.GreaterEqual(start) && l.LessEqual(end)