ed

[hare] The standard editor
Log | Files | Refs | README | LICENSE

commit c039cba602527c25f4636093189b859adefd80be
parent d63c3dd4a73f41d3a2bd76ea18638ca38eb67428
Author: Byron Torres <b@torresjrjr.com>
Date:   Mon, 15 Jan 2024 22:21:32 +0000

cmd_substitute(): error on NoMatch

Diffstat:
Mcommand.ha | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/command.ha b/command.ha @@ -481,6 +481,8 @@ fn cmd_substitute(s: *Session, cmd: *Command) (void | Error) = { defer free(replacement); const count = if (cmd.count == 0z) 0z else cmd.count - 1z; + let changes = 0z; + for (let n = a; n <= b; n += 1) { const old = s.buf.lines[n].text; const results = regex::findall(&re, old); @@ -522,8 +524,13 @@ fn cmd_substitute(s: *Session, cmd: *Command) (void | Error) = { s.buf.cursor = n + i; }; + + changes += 1; }; + if (changes == 0) + return NoMatch; + printmode(s, cmd)?; };