-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathsshExtension.ts
More file actions
68 lines (58 loc) · 2.16 KB
/
Copy pathsshExtension.ts
File metadata and controls
68 lines (58 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as vscode from "vscode";
export const REMOTE_SSH_EXTENSION_IDS = [
"jeanp413.open-remote-ssh",
"codeium.windsurf-remote-openssh",
"anysphere.remote-ssh",
"ms-vscode-remote.remote-ssh",
"google.antigravity-remote-openssh",
] as const;
export type RemoteSshExtensionId = (typeof REMOTE_SSH_EXTENSION_IDS)[number];
/**
* Extensions that spawn ssh without `-F`, so it always reads ~/.ssh/config
* and their renamed configFile setting never applies.
*/
const IGNORED_CONFIG_FILE: readonly RemoteSshExtensionId[] = [
"google.antigravity-remote-openssh",
"codeium.windsurf-remote-openssh",
];
/** The SSH config file the active extension connects through, if configured. */
export function getRemoteSshConfigFile(): string | undefined {
const id = getRemoteSshExtension()?.id;
if (id && IGNORED_CONFIG_FILE.includes(id)) {
return undefined;
}
return (
vscode.workspace.getConfiguration("remote.SSH").get<string>("configFile") ||
undefined
);
}
/**
* VS Code Remote-SSH log layout, shared by the live SSH monitor and the
* support-bundle collector so a future layout change updates one place.
*/
const OUTPUT_LOGGING_DIR_PREFIX = "output_logging_";
const REMOTE_SSH_LOG_NAME_FRAGMENT = "Remote - SSH";
/** True if `dirName` is the exthost dir of a known Remote-SSH extension. */
export function isRemoteSshExtensionDir(dirName: string): boolean {
return (REMOTE_SSH_EXTENSION_IDS as readonly string[]).includes(dirName);
}
/** True if `dirName` is a VS Code shared output channel dir. */
export function isOutputLoggingDir(dirName: string): boolean {
return dirName.startsWith(OUTPUT_LOGGING_DIR_PREFIX);
}
/** True if `fileName` is the Remote-SSH log inside a shared output channel. */
export function isSharedChannelRemoteSshLog(fileName: string): boolean {
return fileName.includes(REMOTE_SSH_LOG_NAME_FRAGMENT);
}
type RemoteSshExtension = vscode.Extension<unknown> & {
id: RemoteSshExtensionId;
};
export function getRemoteSshExtension(): RemoteSshExtension | undefined {
for (const id of REMOTE_SSH_EXTENSION_IDS) {
const extension = vscode.extensions.getExtension(id);
if (extension) {
return extension as RemoteSshExtension;
}
}
return undefined;
}