Skip to content

Commit 2725acb

Browse files
authored
Don't write into settings when we cannot honor the user given output folder (#356)
1 parent b541df3 commit 2725acb

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/configuration.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,25 +1162,16 @@ export async function initFromStateAndSettings(): Promise<void> {
11621162

11631163
subKey = "extensionOutputFolder";
11641164
let updatedExtensionOutputFolder : string | undefined = workspaceConfiguration.get<string>(subKey);
1165-
let switchedToDefault: boolean = false;
11661165
if (updatedExtensionOutputFolder) {
11671166
updatedExtensionOutputFolder = util.resolvePathToRoot(updatedExtensionOutputFolder);
1168-
if (!util.checkDirectoryExistsSync(updatedExtensionOutputFolder)) {
1169-
logger.message(`Provided extension output folder does not exist: ${updatedExtensionOutputFolder}.`);
1170-
let defaultExtensionOutputFolder: string | undefined = workspaceConfiguration.inspect<string>(subKey)?.defaultValue;
1171-
if (defaultExtensionOutputFolder) {
1172-
logger.message(`Switching to default: ${defaultExtensionOutputFolder}.`);
1173-
updatedExtensionOutputFolder = util.resolvePathToRoot(defaultExtensionOutputFolder);
1174-
// This will trigger another settings changed event
1175-
workspaceConfiguration.update(subKey, defaultExtensionOutputFolder);
1176-
updatedSettingsSubkeys.push(subKey);
1177-
// to prevent the below readExtensionOutputFolder to be executed now,
1178-
// it will during the next immediate changed event
1179-
switchedToDefault = true;
1180-
}
1181-
}
1167+
if (!util.checkDirectoryExistsSync(updatedExtensionOutputFolder) &&
1168+
!util.createDirectorySync(updatedExtensionOutputFolder)) {
1169+
// No logging necessary about not being able to create the directory,
1170+
// readExtensionOutputFolder called below will complain if it's the case.
1171+
updatedExtensionOutputFolder = undefined;
1172+
}
11821173
}
1183-
if (updatedExtensionOutputFolder !== extensionOutputFolder && !switchedToDefault) {
1174+
if (updatedExtensionOutputFolder !== extensionOutputFolder) {
11841175
// No IntelliSense update needed.
11851176
readExtensionOutputFolder();
11861177
updatedSettingsSubkeys.push(subKey);

0 commit comments

Comments
 (0)