diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-02 00:58:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-02 00:58:20 -0300 |
| commit | 39d4a7c38b12f907d8ba6c08bb14600b503a13d7 (patch) | |
| tree | 7ab29d0a3ebe12958019ef46d58e68506d91d615 /src/builtins.zig | |
| parent | 6637d8df988f8cff9d054c39d3781f4a1ede3b8e (diff) | |
| download | pardes-39d4a7c38b12f907d8ba6c08bb14600b503a13d7.tar.gz pardes-39d4a7c38b12f907d8ba6c08bb14600b503a13d7.zip | |
Get of a file not there, or of a directory, says so before asking about unsaved edits; the init file saved in a pane logs a bad line as err - init file line N, as startup does, its commands still not run again
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index c42d4978..77e1169d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1150,10 +1150,18 @@ pub const Get = struct { return panes.Dir.show(c.p, c.id, c.id); } if (!panes.Output.fileTraits(f.output).saves) return c.p.reportFailure(c.id, "Get: only a file pane takes it"); - if (ctl.getRefused(c.p, c.pane, "Get")) |said| return c.p.reportFailure(c.id, said); var failed: anyerror = error.Unexpected; var home_buf: [4096]u8 = undefined; const path = if (typed.len == 0) c.pane.file.?.path else std.fs.path.resolvePosix(c.p.scratch.allocator(), &.{ Pardes.paneDir(c.pane), @import("fs.zig").expandHome(typed, &home_buf) }) catch return; + // A file that is not there, or a directory, is said before unsaved + // edits are asked about: there would be nothing to load over them. + if (comptime pardes.hosted) if (typed.len > 0) if (@import("fs.zig").localPath(path)) |local| { + var said: [320]u8 = undefined; + const kind = exec.kindOf(local); + if (kind == null or kind.? == .directory) + return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Get: {s}: {s}", .{ path[0..@min(path.len, 256)], if (kind == null) "no such file" else "is a directory" }) catch "Get: no such file"); + }; + if (ctl.getRefused(c.p, c.pane, "Get")) |said| return c.p.reportFailure(c.id, said); const errno = if (typed.len == 0) ctl.get(c.p, c.pane, &failed) else ctl.getFile(c.p, c.pane, path, &failed); if (errno != 0) { var said: [320]u8 = undefined; |
