summaryrefslogtreecommitdiff
path: root/src/File.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 13:16:18 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:56:36 -0300
commita821fe82d8de3d407ebe104358b97719bd983727 (patch)
tree46301f10f599983fc1be9b9ac38df8d2e6d0bf71 /src/File.zig
parentd78fa4f9d90437dac60d9150e3a6eca868895856 (diff)
downloadpardes-a821fe82d8de3d407ebe104358b97719bd983727.tar.gz
pardes-a821fe82d8de3d407ebe104358b97719bd983727.zip
idioms #19, unreachable only where the type bounds it: the prints that carry a path, a name, a miss or a reason (Core's shell and Dump words, colors' theme file, look's misses and refusals) cut through Kind.Buf at their old size, the header texts flatSurface could still fail on and colors' putName handle the failure again, and every kept site (integers, a same-statement cut into a [K + room] buffer, the hashing and discarding writers) says its bound on its line
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/File.zig')
-rw-r--r--src/File.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/File.zig b/src/File.zig
index 01c605bf..1c40379d 100644
--- a/src/File.zig
+++ b/src/File.zig
@@ -1512,9 +1512,9 @@ pub fn deleted(p: *Pardes, id: u8) void {
if (f.disk_gone) return;
f.disk_gone = true;
var said: [limits.host_path_cap + 64]u8 = undefined;
- p.setMessage(id, std.fmt.bufPrint(&said, "{s} deleted on disk (Save writes it again)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable);
+ p.setMessage(id, std.fmt.bufPrint(&said, "{s} deleted on disk (Save writes it again)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable); // cap + 52 fits cap + 64
var rec: [32]u8 = undefined;
- pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} deleted", .{pane.serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} deleted", .{pane.serial}) catch unreachable); // a u32 fits 32
}
/// A file rewritten on disk. A clean buffer takes the new text, committed
@@ -1539,15 +1539,15 @@ pub fn changed(p: *Pardes, id: u8, bytes: []const u8) void {
f.disk_newer = disk;
f.disk_newer_warned = false;
var said: [limits.host_path_cap + 64]u8 = undefined;
- p.setMessage(id, std.fmt.bufPrint(&said, "{s} changed on disk (get reloads it, Save overwrites it)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable);
+ p.setMessage(id, std.fmt.bufPrint(&said, "{s} changed on disk (get reloads it, Save overwrites it)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}) catch unreachable); // cap + 52 fits cap + 64
var rec: [16]u8 = undefined;
- pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d}", .{pane.serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d}", .{pane.serial}) catch unreachable); // a u32 fits 16
return;
};
f.disk_newer = null;
// Logged as the dirty case is, with what became of it.
var rec: [32]u8 = undefined;
- pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} reloaded", .{pane.serial}) catch unreachable); // a u32
+ pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} reloaded", .{pane.serial}) catch unreachable); // a u32 fits 32
const new = p.gpa.dupe(u8, bytes) catch |err| return p.reportError(id, "reload", err);
pushUndo(p, pane);
setContent(p, f, new);