@@ -16,19 +16,6 @@ function isRemoteSshInstalled(): boolean {
1616 ) ;
1717}
1818
19- /**
20- * Get the ID of the installed Remote-SSH extension
21- */
22- function getRemoteSshExtensionId ( ) : string | undefined {
23- if ( vscode . extensions . getExtension ( "ms-vscode-remote.remote-ssh" ) ) {
24- return "ms-vscode-remote.remote-ssh" ;
25- }
26- if ( vscode . extensions . getExtension ( "anysphere.remote-ssh" ) ) {
27- return "anysphere.remote-ssh" ;
28- }
29- return undefined ;
30- }
31-
3219/**
3320 * Open a local workspace in a new VS Code window
3421 */
@@ -50,22 +37,22 @@ async function openLocalWorkspace(workspace: WorkspaceWithContext) {
5037async function openSshWorkspace ( workspace : WorkspaceWithContext ) {
5138 // Check if Remote-SSH is installed
5239 if ( ! isRemoteSshInstalled ( ) ) {
53- vscode . window . showErrorMessage (
40+ const selection = await vscode . window . showErrorMessage (
5441 'cmux: The "Remote - SSH" extension is required to open SSH workspaces. ' +
5542 "Please install it from the Extensions marketplace." ,
5643 "Open Extensions"
57- ) . then ( ( selection ) => {
58- if ( selection === "Open Extensions" ) {
59- // Search for the appropriate extension based on the editor
60- const extensionId = vscode . env . appName . toLowerCase ( ) . includes ( "cursor" )
61- ? "anysphere.remote-ssh"
62- : "ms-vscode-remote .remote-ssh";
63- vscode . commands . executeCommand (
64- "workbench.extensions.search" ,
65- `@id: ${ extensionId } `
66- ) ;
67- }
68- } ) ;
44+ ) ;
45+
46+ if ( selection === "Open Extensions" ) {
47+ // Search for the appropriate extension based on the editor
48+ const extensionId = vscode . env . appName . toLowerCase ( ) . includes ( "cursor" )
49+ ? "anysphere .remote-ssh"
50+ : "ms- vscode-remote.remote-ssh" ;
51+ await vscode . commands . executeCommand (
52+ "workbench.extensions.search" ,
53+ `@id: ${ extensionId } `
54+ ) ;
55+ }
6956 return ;
7057 }
7158
@@ -91,18 +78,16 @@ async function openSshWorkspace(workspace: WorkspaceWithContext) {
9178 { forceNewWindow : true }
9279 ) ;
9380 } catch ( error ) {
94- vscode . window . showErrorMessage (
81+ const selection = await vscode . window . showErrorMessage (
9582 `cmux: Failed to open SSH workspace on host "${ host } ". ` +
9683 `Make sure the host is configured in your ~/.ssh/config or in the Remote-SSH extension. ` +
9784 `Error: ${ error instanceof Error ? error . message : String ( error ) } ` ,
9885 "Open SSH Config"
99- ) . then ( ( selection ) => {
100- if ( selection === "Open SSH Config" ) {
101- vscode . commands . executeCommand (
102- "remote-ssh.openConfigFile"
103- ) ;
104- }
105- } ) ;
86+ ) ;
87+
88+ if ( selection === "Open SSH Config" ) {
89+ await vscode . commands . executeCommand ( "remote-ssh.openConfigFile" ) ;
90+ }
10691 }
10792}
10893
0 commit comments