@@ -203,6 +203,30 @@ func startWorkspaceIfStopped(t *terminal.Terminal, tstore OpenStore, wsIDOrName
203
203
return nil
204
204
}
205
205
206
+ func tryToInstallExtensions (
207
+ t * terminal.Terminal ,
208
+ extIDs []string ,
209
+ ) error {
210
+ for _ , extID := range extIDs {
211
+ extInstalled , err0 := uutil .IsVSCodeExtensionInstalled (extID )
212
+ if ! extInstalled {
213
+ err1 := uutil .InstallVscodeExtension (extID )
214
+ isRemoteInstalled , err2 := uutil .IsVSCodeExtensionInstalled (extID )
215
+ if ! isRemoteInstalled {
216
+ err := multierror .Append (err0 , err1 , err2 )
217
+ t .Print (t .Red ("Couldn't install the necessary VSCode extension automatically.\n Error: " + err .Error ()))
218
+ t .Print ("\t Please install VSCode and the following VSCode extension: " + t .Yellow (extID ) + ".\n " )
219
+ _ = terminal .PromptGetInput (terminal.PromptContent {
220
+ Label : "Hit enter when finished:" ,
221
+ ErrorMsg : "error" ,
222
+ AllowEmpty : true ,
223
+ })
224
+ }
225
+ }
226
+ }
227
+ return nil
228
+ }
229
+
206
230
// Opens code editor. Attempts to install code in path if not installed already
207
231
func openVsCodeWithSSH (
208
232
t * terminal.Terminal ,
@@ -231,37 +255,15 @@ func openVsCodeWithSSH(
231
255
s .Stop ()
232
256
t .Vprintf ("\n " )
233
257
234
- // Check if user uses VSCode and intall extension for user
235
- isInstalled , err := uutil .IsVSCodeExtensionInstalled ("ms-vscode-remote.remote-ssh" )
258
+ err = tryToInstallExtensions (t , []string {"ms-vscode-remote.remote-ssh" , "ms-toolsai.jupyter-keymap" , "ms-python.python" })
236
259
if err != nil {
237
- t .Print (t .Red ("Couldn't install the necessary VSCode extension automatically." ))
238
- t .Print ("\t Please install VSCode and the following VSCode extension: " + t .Yellow ("ms-vscode-remote.remote-ssh" ) + ".\n " )
239
- _ = terminal .PromptGetInput (terminal.PromptContent {
240
- Label : "Hit enter when finished:" ,
241
- ErrorMsg : "error" ,
242
- AllowEmpty : true ,
243
- })
244
- }
245
- // If we couldn't check for the extension being installed, they likely don't have code in path and this step should be skipped
246
- if ! isInstalled && err == nil {
247
- // attempt to install the extension
248
- _ = uutil .InstallVscodeExtension ("ms-vscode-remote.remote-ssh" )
249
-
250
- // verify installation
251
- isInstalled , err = uutil .IsVSCodeExtensionInstalled ("ms-vscode-remote.remote-ssh" )
252
- // tell the user to install manually if still not installed
253
- if ! isInstalled || err != nil {
254
- t .Print (t .Red ("Couldn't install the necessary VSCode extension automatically." ))
255
- t .Print ("\t Please install VSCode and the following VSCode extension: " + t .Yellow ("ms-vscode-remote.remote-ssh" ) + ".\n " )
256
- _ = terminal .PromptGetInput (terminal.PromptContent {
257
- Label : "Hit enter when finished:" ,
258
- ErrorMsg : "error" ,
259
- AllowEmpty : true ,
260
- })
261
- }
260
+ return breverrors .WrapAndTrace (err )
262
261
}
263
262
264
263
err = openVsCode (sshAlias , path , tstore )
264
+ if err != nil {
265
+ return breverrors .WrapAndTrace (err )
266
+ }
265
267
266
268
// check if we are in a brev environment, if so transform the error message
267
269
// to indicate that the user should run brev open locally instead of in
0 commit comments