Fix macOS GUI file loading: resolve CLI paths before chdir

On macOS GUI builds, chdir(HOME) runs before deferred file opens are
processed, breaking relative paths passed on the command line. Resolve
each argv path to absolute immediately during argument parsing.

Bump version to 1.11.2.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-15 15:20:36 -07:00
parent 6413e14455
commit 056c9af38e
2 changed files with 14 additions and 2 deletions

14
main.cc
View File

@@ -12,6 +12,7 @@
#include <random>
#include <thread>
#include <signal.h>
#include <filesystem>
#include <string>
#include <unistd.h>
#include <sys/stat.h>
@@ -255,7 +256,18 @@ main(int argc, char *argv[])
// Fall through: not a +number, treat as filename starting with '+'
}
const std::string path = arg;
// Resolve to absolute path now, before any
// chdir (macOS GUI changes CWD to HOME before
// deferred opens are processed).
std::string path = arg;
try {
std::filesystem::path p(path);
if (p.is_relative()) {
path = std::filesystem::absolute(p).string();
}
} catch (...) {
// Fall through with original path
}
editor.RequestOpenFile(path, pending_line);
pending_line = 0; // consumed (if set)
}