commit 6837a8f2cbbdc264b067af0761106b3bc3158b8d
parent 1688cc17562b1216b8efa45ffee320587a2cd2c1
Author: Byron Torres <b@torresjrjr.com>
Date: Wed, 10 Jan 2024 23:12:47 +0000
impr variable names
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/command.ha b/command.ha
@@ -477,23 +477,23 @@ fn cmd_substitute(s: *Session, cmd: *Command) (void | Error) = {
// use regex::replace ?
// TODO: implement '&', '%'
- for (let i = a; i <= b; i += 1) {
- const old = s.buf.lines[i].text;
+ for (let n = a; n <= b; n += 1) {
+ const old = s.buf.lines[n].text;
const results = regex::findall(&re, old);
defer regex::result_freeall(results);
if (len(results) == 0)
continue;
- let iter = strings::iter(s.buf.lines[i].text);
+ let iter = strings::iter(s.buf.lines[n].text);
let new = memio::dynamic(); defer io::close(&new)!;
let start = 0z;
let lbound = 0z;
let rbound = 0z;
- for (let j = 0z; j < len(results); j += 1) {
- lbound = results[j][0].start;
- rbound = results[j][0].end;
+ for (let i = 0z; i < len(results); i += 1) {
+ lbound = results[i][0].start;
+ rbound = results[i][0].end;
memio::concat(&new, strings::sub(old, start, lbound))!;
memio::concat(&new, replacement)!;
start = rbound;
@@ -505,8 +505,8 @@ fn cmd_substitute(s: *Session, cmd: *Command) (void | Error) = {
...
});
- buf_delete(s.buf, i, i);
- buf_insert(s.buf, i, newline);
+ buf_delete(s.buf, n, n);
+ buf_insert(s.buf, n, newline);
};
printmode(s, cmd)?;