summaryrefslogtreecommitdiff
path: root/src/Pipe.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 12:40:11 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:56:36 -0300
commita66a9eb6e0c69cfcb63717bc27704cdc96f382b4 (patch)
tree400e3034a6c71c1d15d0ad302e1293a4290071b9 /src/Pipe.zig
parent36a51ddc67d0beb7d9851fb2425cf780a47fed36 (diff)
downloadpardes-a66a9eb6e0c69cfcb63717bc27704cdc96f382b4.tar.gz
pardes-a66a9eb6e0c69cfcb63717bc27704cdc96f382b4.zip
idioms #11, the command layer: exec, builtins, edit_cmd, Messages, Dir, Output, Jump and Pipe say their messages through buffers proven big enough (or the long argument cut) instead of placeholder text, replId takes its 48-byte buffer, a failed Save path, Get or Incl path, Repl send, Tutor, +Unsaved, pipe or Edit output on OOM is reported (reportError) rather than silently dropped, Edit's why and zonWhy cut a long text instead of losing it, and writeFailure names its set
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Pipe.zig')
-rw-r--r--src/Pipe.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Pipe.zig b/src/Pipe.zig
index e7895c0d..87768f22 100644
--- a/src/Pipe.zig
+++ b/src/Pipe.zig
@@ -103,7 +103,7 @@ pub fn submitPipe(p: *Pardes, id: usize) void {
const f = pane.file orelse return;
if (!panes.Output.fileTraits(f.output).saves) return;
}
- const content = edit.flatSurface(p, t) catch return;
+ const content = edit.flatSurface(p, t) catch |err| return p.reportError(id, "pipe", err);
const how = switch (pane.prompt) {
.pipe => |pipe| pipe,
else => return,
@@ -174,11 +174,11 @@ fn pipeFailed(p: *Pardes, wait: *const PendingPipe, failure: ?selection_pipe.Fai
var out: std.Io.Writer.Allocating = .init(p.gpa);
defer out.deinit();
const w = &out.writer;
- w.print("| {s}\n\n", .{wait.command}) catch return;
+ w.print("| {s}\n\n", .{wait.command}) catch |err| return p.reportError(wait.pane, "pipe", err);
if (wait.inputs.len > 1) if (failure) |fail|
- w.print("selection {d} of {d}: ", .{ fail.index + 1, wait.inputs.len }) catch return;
- writeFailure(w, failure) catch return;
- const content = out.toOwnedSlice() catch return;
+ w.print("selection {d} of {d}: ", .{ fail.index + 1, wait.inputs.len }) catch |err| return p.reportError(wait.pane, "pipe", err);
+ writeFailure(w, failure) catch |err| return p.reportError(wait.pane, "pipe", err);
+ const content = out.toOwnedSlice() catch |err| return p.reportError(wait.pane, "pipe", err);
const was = p.view().active;
panes.Output.openErrors(p, wait.pane, content) catch |err| {
p.gpa.free(content);
@@ -191,7 +191,7 @@ fn pipeFailed(p: *Pardes, wait: *const PendingPipe, failure: ?selection_pipe.Fai
/// How a filter failed, a line, and the command's stderr after it: what
/// +Errors says of a `|` and of an Edit's `< | >`.
-pub fn writeFailure(w: *std.Io.Writer, failure: ?selection_pipe.Failure) !void {
+pub fn writeFailure(w: *std.Io.Writer, failure: ?selection_pipe.Failure) std.Io.Writer.Error!void {
const fail = failure orelse {
// No diagnosis at all: nobody ran it. The detached daemon leaves
// `pipe` null on purpose.
@@ -267,7 +267,7 @@ pub fn pipeResponse(
.workspace => &p.global_tag,
.input => return,
};
- const content = edit.flatSurface(p, t) catch return;
+ const content = edit.flatSurface(p, t) catch |err| return p.reportError(wait.pane, "pipe", err);
const changed = if (t.what == .body) changed: {
const f = pane.file orelse return;
if (!panes.Output.fileTraits(f.output).saves) return;
@@ -301,12 +301,12 @@ pub fn pipeResponse(
const cut = pipeCut(&wait, content, i) orelse return;
const output = pipeOutput(&wait, outputs, content, i);
if (output.len > selection_pipe.max_stdout_bytes) return;
- total_output = std.math.add(usize, total_output, output.len) catch return;
+ total_output = std.math.add(usize, total_output, output.len) catch unreachable; // both are capped far below a usize's room
if (total_output > selection_pipe.max_total_stdout_bytes) return;
if (i > 0 and cut.lo < ops[i - 1].q1) return;
ops[i] = .{ .q0 = @intCast(cut.lo), .q1 = @intCast(cut.hi), .text = output };
}
- const replacement = sam.apply(p.gpa, content, ops[0..n]) catch return;
+ const replacement = sam.apply(p.gpa, content, ops[0..n]) catch |err| return p.reportError(wait.pane, "pipe", err);
var new_ranges: [panes.Text.max_selections]modal.Selection = undefined;
var delta: isize = 0;
for (ops[0..n], wait.ranges[0..n], new_ranges[0..n]) |op, range, *moved| {