summaryrefslogtreecommitdiff
path: root/core/sam_edit.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/sam_edit.zig')
-rw-r--r--core/sam_edit.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/sam_edit.zig b/core/sam_edit.zig
index 39f667f9..4d7d6a27 100644
--- a/core/sam_edit.zig
+++ b/core/sam_edit.zig
@@ -83,6 +83,8 @@ pub const World = struct {
/// `e` over unsaved edits in the pane `id`: asked once, as Get asks;
/// true, and `why` set, when it is refused this time.
refuseGet: *const fn (ctx: *anyopaque, id: usize, why: *Why) bool,
+ /// What `~` is: the session's home (null: none).
+ home: ?[]const u8 = null,
};
/// What an Edit came to: every file (those `B` opened after the ones it
@@ -668,7 +670,7 @@ const Exec = struct {
fn pathIn(ex: *Exec, fi: usize, name_in: []const u8) Failure![]const u8 {
// `~` and `~user` as Get, Incl and Save read them.
var home: [4096]u8 = undefined;
- const name = try ex.arena.dupe(u8, @import("fs.zig").expandHome(name_in, &home));
+ const name = try ex.arena.dupe(u8, @import("fs.zig").expandHomeFrom(name_in, &home, if (ex.world) |w| w.home else null));
if (name.len > 0 and name[0] == '/') return name;
const dir = std.Io.Dir.path.dirnamePosix(ex.files.items[fi].name) orelse "/";
return std.Io.Dir.path.resolvePosix(ex.arena, &.{ dir, name });
@@ -1126,7 +1128,7 @@ const Fixture = struct {
fn edit(fx: *Fixture, from: usize, command: []const u8) !Result {
var ctx: u8 = 0;
- const world: World = .{ .ctx = &ctx, .check = check, .open = open, .read = read, .refuseGet = refuseGet };
+ const world: World = .{ .ctx = &ctx, .check = check, .open = open, .read = read, .refuseGet = refuseGet, .home = "/home/u" };
return run(fx.arena_state.allocator(), &files, from, command, world, &fx.why);
}