Skip to content

Commit 34bf004

Browse files
authored
Only write dev.containers.defaultExtensions setting if devcontainers extension is installed (#116)
1 parent 05ae415 commit 34bf004

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Gitpod",
44
"description": "Gitpod Support",
55
"publisher": "gitpod",
6-
"version": "0.0.178",
6+
"version": "0.0.179",
77
"license": "MIT",
88
"icon": "resources/gitpod.png",
99
"repository": {

src/services/remoteService.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ export class RemoteService extends Disposable implements IRemoteService {
331331

332332
async updateRemoteConfig() {
333333
const remoteSSHconfig = vscode.workspace.getConfiguration('remote.SSH');
334-
const defaultSSHExtConfigInfo =
335-
remoteSSHconfig.inspect<string[]>('defaultExtensions');
334+
const defaultSSHExtConfigInfo = remoteSSHconfig.inspect<string[]>('defaultExtensions');
336335
const defaultSSHExtensions = defaultSSHExtConfigInfo?.globalValue ?? [];
337336
if (!defaultSSHExtensions.includes('gitpod.gitpod-remote-ssh')) {
338337
defaultSSHExtensions.unshift('gitpod.gitpod-remote-ssh');
@@ -343,17 +342,19 @@ export class RemoteService extends Disposable implements IRemoteService {
343342
);
344343
}
345344

346-
const remoteDevContainerConfig =
347-
vscode.workspace.getConfiguration('dev.containers');
348-
const defaultDevContainerExtConfigInfo = remoteDevContainerConfig.inspect<string[]>('defaultExtensions');
349-
const defaultDevContainerExtensions = defaultDevContainerExtConfigInfo?.globalValue ?? [];
350-
if (!defaultDevContainerExtensions.includes('gitpod.gitpod-remote-ssh')) {
351-
defaultDevContainerExtensions.unshift('gitpod.gitpod-remote-ssh');
352-
await remoteDevContainerConfig.update(
353-
'defaultExtensions',
354-
defaultDevContainerExtensions,
355-
vscode.ConfigurationTarget.Global,
356-
);
345+
const msVscodeRemoteContainersExt = vscode.extensions.getExtension('ms-vscode-remote.remote-containers');
346+
if (msVscodeRemoteContainersExt) {
347+
const remoteDevContainerConfig = vscode.workspace.getConfiguration('dev.containers');
348+
const defaultDevContainerExtConfigInfo = remoteDevContainerConfig.inspect<string[]>('defaultExtensions');
349+
const defaultDevContainerExtensions = defaultDevContainerExtConfigInfo?.globalValue ?? [];
350+
if (!defaultDevContainerExtensions.includes('gitpod.gitpod-remote-ssh')) {
351+
defaultDevContainerExtensions.unshift('gitpod.gitpod-remote-ssh');
352+
await remoteDevContainerConfig.update(
353+
'defaultExtensions',
354+
defaultDevContainerExtensions,
355+
vscode.ConfigurationTarget.Global,
356+
);
357+
}
357358
}
358359

359360
const currentConfigFile = remoteSSHconfig.get<string>('configFile');

0 commit comments

Comments
 (0)