Skip to content

Commit 597b9f6

Browse files
committed
fix: error when disabling uninstalled addon
1 parent 263e90a commit 597b9f6

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

client/src/addon_manager/models/addon.ts

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,27 +199,37 @@ export class Addon {
199199
return;
200200
}
201201

202-
// Remove setting for Language Server
202+
// Remove this addon from the library list
203203
librarySetting.splice(index, 1);
204-
const configValues = await this.getConfigurationFile();
205-
206-
// Revoke settings
207-
try {
208-
await setConfig([
209-
{
210-
action: "set",
211-
key: LIBRARY_SETTING,
212-
value: librarySetting,
213-
uri: folder.uri,
214-
},
215-
]);
216-
if (configValues.settings)
217-
await revokeAddonSettings(folder, configValues.settings);
218-
} catch (e) {
219-
localLogger.error(`Failed to revoke settings of "${this.name}"`);
204+
const result = await setConfig([
205+
{
206+
action: "set",
207+
key: LIBRARY_SETTING,
208+
value: librarySetting,
209+
uri: folder.uri,
210+
},
211+
]);
212+
if (!result) {
213+
localLogger.error(
214+
`Failed to update ${LIBRARY_SETTING} when disabling ${this.name}`
215+
);
220216
return;
221217
}
222218

219+
// Remove addon settings if installed
220+
if (this.#installed) {
221+
const configValues = await this.getConfigurationFile();
222+
try {
223+
if (configValues.settings)
224+
await revokeAddonSettings(folder, configValues.settings);
225+
} catch (e) {
226+
localLogger.error(
227+
`Failed to revoke settings of "${this.name}"`
228+
);
229+
return;
230+
}
231+
}
232+
223233
this.#enabled[folder.index] = false;
224234
localLogger.info(`Disabled "${this.name}"`);
225235
}

client/src/addon_manager/services/settings.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const getLibraryPaths = async (): Promise<
2222
const result = [];
2323

2424
for (const folder of vscode.workspace.workspaceFolders) {
25-
const libraries = (await getConfig(LIBRARY_SETTING, folder.uri)) ?? [];
26-
result.push({ folder, paths: libraries });
25+
const libraries = await getConfig(LIBRARY_SETTING, folder.uri);
26+
result.push({ folder, paths: libraries ?? [] });
2727
}
2828

2929
return result;

0 commit comments

Comments
 (0)