diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 3b7d6abe..afa72881 100644 --- a/src/main.zig +++ b/src/main.zig @@ -744,6 +744,7 @@ fn nativeMain(std_init: std.process.Init) !void { opts.startup_config_path = found.path; opts.config_dir = found.dir; opts.state = .disk; + opts.recent_import = oldRecentDir(arena, init.environ_map); if (found.dir) |d| @import("crash.zig").setDir(d); if (attach) |name| if (std.mem.lastIndexOfScalar(u8, name, ':')) |colon| { remoteAttach(init, opts, name[0..colon], name[colon + 1 ..]); @@ -1099,3 +1100,14 @@ test { if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig"); if (comptime pardes.font_picker) _ = @import("fonts.zig"); } + +/// Where Recent's file (0.24) and the store before it were kept: +/// $XDG_STATE_HOME/pardes, else ~/.local/state/pardes. A state file that +/// holds no Recent yet reads them once (Db.zig). +fn oldRecentDir(arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 { + if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.fs.path.isAbsolute(base)) + return std.fs.path.join(arena, &.{ base, "pardes" }) catch null; + const home = env.get("HOME") orelse return null; + if (home.len == 0) return null; + return std.fs.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch null; +} |
