Files
NetMesh/components/terminalLayer/commandCwdProbe.ts

29 lines
865 B
TypeScript
Raw Normal View History

import { resolveHostFollowTerminalCwd, resolveSftpFollowTerminalCwdTargetHost } from "../../domain/sftpFollowTerminalCwd";
type FollowTerminalCwdHost = {
sftpFollowTerminalCwd?: boolean;
};
type ShouldProbeCommandCwdOptions = {
restoreTerminalCwd: boolean;
visibleSftpHost?: FollowTerminalCwdHost | null;
sessionHost?: FollowTerminalCwdHost | null;
globalSftpFollowTerminalCwd: boolean;
};
export const shouldProbeCommandCwd = ({
restoreTerminalCwd,
visibleSftpHost,
sessionHost,
globalSftpFollowTerminalCwd,
}: ShouldProbeCommandCwdOptions): boolean => {
if (restoreTerminalCwd) return true;
if (!visibleSftpHost) return false;
const followHost = resolveSftpFollowTerminalCwdTargetHost(visibleSftpHost, sessionHost);
return resolveHostFollowTerminalCwd(
followHost?.sftpFollowTerminalCwd,
globalSftpFollowTerminalCwd,
);
};