diff options
Diffstat (limited to 'core/Effect.zig')
| -rw-r--r-- | core/Effect.zig | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/core/Effect.zig b/core/Effect.zig index bc952b8b..f0e18335 100644 --- a/core/Effect.zig +++ b/core/Effect.zig @@ -184,7 +184,7 @@ fn performInner(p: *Pardes, e: Effect) void { return; } if (!pane.isTerminal()) return; - const text = pardes.Term.scrollback(pane.terminal, p.gpa) catch |err| return p.reportError(st.pane, "Save", err); + const text = pardes.Term.scrollback(pane.terminal, p.gpa) catch |err| return p.reportError(.at(st.pane), "Save", err); defer p.gpa.free(text); if (writeChecked(p, st.pane, st.serial, st.path.slice(), text, 0)) |still| ctlfs.events.noteLogAs(p, .save, still, st.path.slice()); @@ -259,7 +259,7 @@ fn performInner(p: *Pardes, e: Effect) void { .detach => |d| if (v.detach) |f| f(p.host.ctx) else - p.reportError(d.pane, "detach", error.NotAttached), + p.reportError(.at(d.pane), "detach", error.NotAttached), // dlopen is the same on every host, so none has a method of its // own; a replica's core holds no library (what it brought comes in // the event this taped). @@ -282,7 +282,7 @@ pub fn writeChecked(p: *Pardes, id: u8, serial: u32, path: []const u8, bytes: [] if (filesystem.localPath(path)) |local| filesystem.makeDirs(p.tape, std.Io.Dir.path.dirname(local) orelse "/"); // The in-process filesystem reports the same way a real host does, // so an OOM there leaves the pane dirty rather than looking saved. - if (p.host.vtable.write_file) |f| f(p.host.ctx, id, path, bytes) else if (!p.fallback.writeFile(path, bytes)) p.saveFailed(id, path, error.OutOfMemory); + if (p.host.vtable.write_file) |f| f(p.host.ctx, id, path, bytes) else if (!p.fallback.writeFile(path, bytes)) p.saveFailed(.at(id), path, error.OutOfMemory); const pane = p.panes[id] orelse return null; if (pane.serial != serial) return null; if (p.fs.failures == failures) return pane; @@ -298,7 +298,7 @@ pub fn writeChecked(p: *Pardes, id: u8, serial: u32, path: []const u8, bytes: [] fn promoteSaved(p: *Pardes, id: u8, path: []const u8) void { const pane = p.panes[id] orelse return; const f = if (pane.file) |*file| file else return; - const owned = p.gpa.dupe(u8, path) catch |err| return p.reportError(id, "Save", err); + const owned = p.gpa.dupe(u8, path) catch |err| return p.reportError(.at(id), "Save", err); p.gpa.free(f.path); f.path = owned; f.output = null; @@ -358,7 +358,7 @@ test "Save on a scratch asks for a path in its inherited dir and makes it a file while (p.nextEffect()) |_| {} const source: usize = 2; - p.setCwd(source, "/tmp/pardes-save-dir"); + p.setCwd(.at(source), "/tmp/pardes-save-dir"); try std.testing.expect(p.executeBuiltinLine(source, "New")); const id = p.view().active; const np = p.panes[id].?; @@ -391,7 +391,7 @@ test "Save on a terminal writes its plaintext scrollback and stays a terminal" { defer p.deinit(); while (p.nextEffect()) |_| {} const pane = p.panes[0].?; - p.setCwd(0, "/tmp/pardes-tty-save"); + p.setCwd(.at(0), "/tmp/pardes-tty-save"); p.update(.{ .output = .{ .pane = 0, .bytes = "hello scrollback\r\n" } }); while (p.nextEffect()) |_| {} @@ -422,7 +422,7 @@ test "Save on an output buffer writes its rows out and leaves the buffer alone" while (p.nextEffect()) |_| {} const source: usize = 2; - p.setCwd(source, "/tmp/pardes-output-save"); + p.setCwd(.at(source), "/tmp/pardes-output-save"); try std.testing.expect(p.executeBuiltinLine(source, "Help")); p.sync(); // the frame boundary that gives the new pane its geometry while (p.nextEffect()) |_| {} @@ -473,7 +473,7 @@ test "Save takes the path as an argument, relative to the pane's own directory" defer p.deinit(); while (p.nextEffect()) |_| {} const pane = p.panes[0].?; - p.setCwd(0, "/tmp/pardes-arg-save"); + p.setCwd(.at(0), "/tmp/pardes-arg-save"); p.update(.{ .output = .{ .pane = 0, .bytes = "typed and gone\r\n" } }); while (p.nextEffect()) |_| {} @@ -512,7 +512,7 @@ test "a save the host could not do leaves the pane dirty" { const Refusing = struct { fn writeFile(ctx: ?*anyopaque, pane: u8, _: []const u8, _: []const u8) void { const core: *Pardes = @ptrCast(@alignCast(ctx.?)); - core.saveFailed(pane, "/x/y.txt", error.PermissionDenied); + core.saveFailed(.at(pane), "/x/y.txt", error.PermissionDenied); } }; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); @@ -576,7 +576,7 @@ test "saves armed in one batch stay with their own panes" { const tty_id = p.freeSlot() orelse return error.NoPaneSlots; const shell = try p.newShell(tty_id, "/tmp/pardes-batch"); - p.setCwd(tty_id, "/tmp/pardes-batch"); + p.setCwd(.at(tty_id), "/tmp/pardes-batch"); p.update(.{ .output = .{ .pane = @intCast(tty_id), .bytes = "shell text\r\n" } }); const file = try p.setTestFile("file text\n"); const file_id = panes.paneIdOf(p, file) orelse return error.MissingFilePane; @@ -659,7 +659,7 @@ test "a save path that names no file is refused before anything is rewritten" { while (p.nextEffect()) |_| {} const source: usize = 2; - p.setCwd(source, "/tmp/pardes-refuse"); + p.setCwd(.at(source), "/tmp/pardes-refuse"); try std.testing.expect(p.executeBuiltinLine(source, "New")); const id = p.view().active; const scratch = p.panes[id].?; @@ -689,7 +689,7 @@ test "a Save the host could not do logs no save record" { const vtable: Host.VTable = .{ .write_file = write }; fn write(ctx: ?*anyopaque, pane: u8, path: []const u8, _: []const u8) void { const f: *@This() = @ptrCast(@alignCast(ctx.?)); - f.core.saveFailed(pane, path, error.AccessDenied); + f.core.saveFailed(.at(pane), path, error.AccessDenied); } }; var host: Failing = .{ .core = p }; |
