summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 8c643be6..55e111e6 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -5842,8 +5842,9 @@ pub const Options = struct {
file: ?[]const u8 = null,
file_line: usize = 0,
/// argv NAMED SOMETHING THAT IS NOT THERE — no file, no directory, nothing
- /// `look.resolve` could make a target of. The word as the human typed it,
- /// and it boots one `+Errors` pane saying so.
+ /// `look.resolve` could make a target of. The word as the human typed it
+ /// and the directory they typed it in, and it boots one `+Errors` pane
+ /// saying so.
///
/// A launch is not a failure worth refusing. `pardes nosuchfile` used to
/// return `BadArgs` out of `main`, which std prints as `error: BadArgs`
@@ -5851,7 +5852,11 @@ pub const Options = struct {
/// typo, and it left the human with no editor at all. Outranked by `file`
/// for the same reason `file` outranks `shells`: only one of them can name
/// the boot layout, and they are never both set.
- missing_path: ?[]const u8 = null,
+ ///
+ /// `dir` is the LAUNCH DIRECTORY, and the pane needs it for the same
+ /// reasons every other pane needs one: it is where a `Grep` from that pane
+ /// walks, where its `Newtty` spawns a shell, and what its `Save` prefills.
+ missing: ?struct { word: []const u8, dir: []const u8 } = null,
tty_toggle: u21 = config.tty_toggle_default,
/// load a dump of another instance instead of spawning shells (acme -l)
load_path: ?[]const u8 = null,
@@ -6333,7 +6338,7 @@ pub const Pardes = struct {
p.ncol = 1;
p.col_n[0] = 1;
p.col_terms[0][0] = 0;
- } else if (opts.missing_path) |word| {
+ } else if (opts.missing) |missing| {
// ARGV NAMED NOTHING. `+Errors` and not the message row, because a
// launch has no pane to put a message row on yet — and because
// this is exactly what acme's `+Errors` is: output from the
@@ -6344,14 +6349,17 @@ pub const Pardes = struct {
//
// The word AS TYPED, not a resolved path: there is nothing to
// resolve, and `pardes ~/notes/tdoo.md` wants to see its own typo
- // back rather than an absolute path built around it.
+ // back rather than an absolute path built around it. The pane's
+ // DIRECTORY is the launch directory all the same — see `missing`:
+ // "" would put this pane at `/+Errors` and point every word that
+ // reads a pane's directory at the root of the filesystem.
const content = try std.fmt.allocPrint(
gpa,
"file or directory not found\n\n\t{s}\n",
- .{word},
+ .{missing.word},
);
errdefer gpa.free(content);
- _ = try output_pane.open(p, 0, "", .errors, "", content);
+ _ = try output_pane.open(p, 0, missing.dir, .errors, "", content);
p.ncol = 1;
p.col_n[0] = 1;
p.col_terms[0][0] = 0;
@@ -16454,7 +16462,11 @@ test "Esc alternates between two panes of the SAME kind" {
test "argv naming nothing boots an errors pane rather than failing the launch" {
const gpa = std.testing.allocator;
- const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .missing_path = "notes/tdoo.md" });
+ const p = try Pardes.init(gpa, .{
+ .cols = 80,
+ .rows = 24,
+ .missing = .{ .word = "notes/tdoo.md", .dir = "/home/pardes-test/work" },
+ });
defer p.deinit();
p.update(.{ .resize = .{ .cols = 80, .rows = 24 } });
@@ -16462,6 +16474,9 @@ test "argv naming nothing boots an errors pane rather than failing the launch" {
// shell a bare `pardes` boots: the answer is the whole screen.
try std.testing.expectEqual(@as(u8, 1), p.ncol);
try std.testing.expectEqual(@as(usize, 1), p.col_n[0]);
+ try std.testing.expectEqual(@as(usize, 0), p.col_terms[0][0]);
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+ for (p.panes[1..]) |slot| try std.testing.expect(slot == null);
const pane = p.panes[0].?;
try std.testing.expect(!pane.isTerminal());
const f = pane.file.?;
@@ -16470,6 +16485,13 @@ test "argv naming nothing boots an errors pane rather than failing the launch" {
// which is the half a bare "not found" leaves out.
try std.testing.expect(std.mem.indexOf(u8, f.content, "not found") != null);
try std.testing.expect(std.mem.indexOf(u8, f.content, "notes/tdoo.md") != null);
+
+ // THE PANE'S DIRECTORY IS THE LAUNCH DIRECTORY, asserted through the path
+ // because that is what `paneDir` reads: it decides where a `Grep` from
+ // this pane walks, where its `Newtty` spawns, and what its `Save`
+ // prefills. Passing "" here put the pane at `/+Errors`, i.e. rooted every
+ // one of those at `/`.
+ try std.testing.expectEqualStrings("/home/pardes-test/work/+Errors", f.path);
}
test "Esc back into a tty leaves its view at the prompt" {