diff --git a/src/webviews/apps/settings/settings.ts b/src/webviews/apps/settings/settings.ts index 81811f9..ed3f328 100644 --- a/src/webviews/apps/settings/settings.ts +++ b/src/webviews/apps/settings/settings.ts @@ -308,7 +308,6 @@ export class SettingsApp extends AppWithConfig { type="button" data-action="hide" data-action-target="autolink" - disabled title="Delete" aria-label="Delete" > diff --git a/src/webviews/apps/shared/appWithConfigBase.ts b/src/webviews/apps/shared/appWithConfigBase.ts index 8c435eb..7e2d740 100644 --- a/src/webviews/apps/shared/appWithConfigBase.ts +++ b/src/webviews/apps/shared/appWithConfigBase.ts @@ -129,20 +129,30 @@ export abstract class AppWithConfig extends Ap const index = parseInt(props[1], 10); const objectProps = props.slice(2); - const setting: Record[] = this.getSettingValue(settingName) ?? []; + let setting: Record[] | undefined = this.getSettingValue(settingName); + if (value == null && (setting === undefined || setting?.length === 0)) { + if (setting !== undefined) { + this._changes[settingName] = undefined; + } + } else { + setting = setting ?? []; - const settingItem = setting[index] ?? Object.create(null); - if (setting[index] === undefined) { - setting[index] = settingItem; - } + let settingItem = setting[index]; + if (value != null || (value == null && settingItem !== undefined)) { + if (settingItem === undefined) { + settingItem = Object.create(null); + setting[index] = settingItem; + } - set( - setting[index], - objectProps.join('.'), - element.type === 'number' && value != null ? Number(value) : value, - ); + set( + settingItem, + objectProps.join('.'), + element.type === 'number' && value != null ? Number(value) : value, + ); - this._changes[settingName] = setting; + this._changes[settingName] = setting; + } + } } else { this._changes[element.name] = element.type === 'number' && value != null ? Number(value) : value; }