Re-run session sync after WASM init and merge Ghostty config files
- Bump a terminal epoch when the deferred WASM setup finishes so the session sync effect re-runs against the live terminal even when no session field changed during the load, completing the exited-at-mount handling - Read config.ghostty as an alternate config file name and merge the XDG and macOS Application Support configs in Ghostty's load order instead of stopping at the first existing file
This commit is contained in:
1 parent
c1caaa3520
commit
36d1cc6578
2 files changed
+24
-7
No files matched your search
@@ -207,13 +207,25 @@ export const loadGhosttyTerminalStyle: Effect.Effect<
|
||||
return undefined;
|
||||
});
|
||||
|
||||
const configSource = yield* readFirstExisting([
|
||||
path.join(xdgConfigHome, "ghostty", "config"),
|
||||
path.join(home, "Library", "Application Support", "com.mitchellh.ghostty", "config"),
|
||||
]);
|
||||
if (configSource === undefined) return undefined;
|
||||
// Ghostty reads the XDG config first and the macOS Application Support
|
||||
// config after it, so later files override earlier values. It also accepts
|
||||
// config.ghostty as the file name. Merge every location that exists instead
|
||||
// of stopping at the first match.
|
||||
const configDirs = [
|
||||
path.join(xdgConfigHome, "ghostty"),
|
||||
path.join(home, "Library", "Application Support", "com.mitchellh.ghostty"),
|
||||
];
|
||||
const configSources: Array<string> = [];
|
||||
for (const dir of configDirs) {
|
||||
const source = yield* readFirstExisting([
|
||||
path.join(dir, "config"),
|
||||
path.join(dir, "config.ghostty"),
|
||||
]);
|
||||
if (source !== undefined) configSources.push(source);
|
||||
}
|
||||
if (configSources.length === 0) return undefined;
|
||||
|
||||
const config = parseGhosttyConfig(configSource);
|
||||
const config = parseGhosttyConfig(configSources.join("\n"));
|
||||
|
||||
const loadThemeColors = (themeName: string) =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -434,6 +434,10 @@ export function TerminalViewport({
|
||||
reportFailure: false,
|
||||
});
|
||||
const hasHandledExitRef = useRef(false);
|
||||
// Bumped when the async WASM gate finishes creating a terminal, so the
|
||||
// session sync effect re-runs against the live terminal even when no
|
||||
// session field changed while the WASM module was loading.
|
||||
const [terminalEpoch, setTerminalEpoch] = useState(0);
|
||||
const selectionPointerRef = useRef<{ x: number; y: number } | null>(null);
|
||||
const selectionGestureActiveRef = useRef(false);
|
||||
const selectionActionRequestIdRef = useRef(0);
|
||||
@@ -549,6 +553,7 @@ export function TerminalViewport({
|
||||
status: "closed",
|
||||
version: 0,
|
||||
};
|
||||
setTerminalEpoch((value) => value + 1);
|
||||
|
||||
const clearSelectionAction = () => {
|
||||
selectionActionRequestIdRef.current += 1;
|
||||
@@ -970,7 +975,7 @@ export function TerminalViewport({
|
||||
});
|
||||
}
|
||||
previousSessionRef.current = current;
|
||||
}, [autoFocus, terminalBuffer, terminalError, terminalStatus, terminalVersion]);
|
||||
}, [autoFocus, terminalBuffer, terminalEpoch, terminalError, terminalStatus, terminalVersion]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!autoFocus) return;
|
||||
|
||||
Reference in new issue
Block a user