summaryrefslogtreecommitdiff
path: root/src/sam_edit.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:02:01 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:16:28 -0300
commit4423bc2f88fe2e88202056d6a11f759b4b143b74 (patch)
tree2e19a95e97a38088a288444b0e298251fe911506 /src/sam_edit.zig
parentadc8a50289f17ba15867f6d8e45844f57ee1aaa8 (diff)
downloadpardes-4423bc2f88fe2e88202056d6a11f759b4b143b74.tar.gz
pardes-4423bc2f88fe2e88202056d6a11f759b4b143b74.zip
modal, selection_pipe, syntax, sam_edit: helpers used once are inlined where they are used (consumeCount, clampLineCol, codepointAtCursor, isWordBoundary, wmIsPrev, tokenStopped, dropDiffPieces, Exec.text), and moveWord's doc comment goes back above moveWord
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/sam_edit.zig')
-rw-r--r--src/sam_edit.zig16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/sam_edit.zig b/src/sam_edit.zig
index 73cd6ecd..b06379f9 100644
--- a/src/sam_edit.zig
+++ b/src/sam_edit.zig
@@ -582,15 +582,11 @@ const Exec = struct {
return std.math.cast(u32, n) orelse std.math.maxInt(u32);
}
- fn text(ex: *const Exec, fi: usize) []const u8 {
- return ex.files.items[fi].text;
- }
-
/// An address in file `fi` from `dot`, or `dot` when there is none
/// (aDot).
fn address(ex: *Exec, fi: usize, expr: ?[]const u8, dot: Range) Failure!Range {
const e = expr orelse return dot;
- var a: addr_lang.Addr = .{ .text = ex.text(fi), .lim = null, .expr = e };
+ var a: addr_lang.Addr = .{ .text = ex.files.items[fi].text, .lim = null, .expr = e };
// A miss names the pattern that missed, not the whole Edit line.
const r = a.address(dot) orelse return if (std.mem.eql(u8, a.err, addr_lang.e_no_match))
fail(ex.why, "no match for regexp {s}", .{e})
@@ -726,7 +722,7 @@ const Exec = struct {
}
// w's default address is the whole file (aAll).
const r = if (c.c == 'w' and c.addr == null)
- Range{ .q0 = 0, .q1 = clip(ex.text(fi).len) }
+ Range{ .q0 = 0, .q1 = clip(ex.files.items[fi].text.len) }
else
try ex.address(fi, c.addr, dot);
const d = try ex.execIn(c, fi, r);
@@ -738,7 +734,7 @@ const Exec = struct {
/// The command itself, at `r` in file `fi`.
fn execIn(ex: *Exec, c: *Cmd, fi: usize, r: Range) Failure!Range {
- const txt = ex.text(fi);
+ const txt = ex.files.items[fi].text;
switch (c.c) {
'\n' => return r,
'a' => {
@@ -948,7 +944,7 @@ const Exec = struct {
/// ecmd.c:443, s_cmd.
fn substitute(ex: *Exec, c: *Cmd, fi: usize, r: Range) Failure!Range {
- const txt = ex.text(fi);
+ const txt = ex.files.items[fi].text;
var rx = try ex.compile(c.re.?, 's');
var n = c.num;
var op: ?usize = null;
@@ -992,7 +988,7 @@ const Exec = struct {
/// ecmd.c:796, looper: the matches (x) or what lies between them (y).
fn looper(ex: *Exec, pat: []const u8, fi: usize, r: Range, xy: bool) Failure![]Range {
- const txt = ex.text(fi);
+ const txt = ex.files.items[fi].text;
var rx = try ex.compile(pat, if (xy) 'x' else 'y');
var out: std.ArrayList(Range) = .empty;
var op: ?usize = if (xy) null else r.q0;
@@ -1026,7 +1022,7 @@ const Exec = struct {
/// ecmd.c:840, linelooper: each line in the range, the first from where
/// the range starts, the last cut where it ends.
fn lines(ex: *Exec, fi: usize, r: Range) Failure![]Range {
- const txt = ex.text(fi);
+ const txt = ex.files.items[fi].text;
var out: std.ArrayList(Range) = .empty;
var p: usize = r.q0;
while (p < r.q1) {