Procházet zdrojové kódy

Improves autolink UI

- prevents writing new empty autolink entries
- cleans up empty autolink arrays
main
Keith Daulton před 2 roky
rodič
revize
c1a848ec33
2 změnil soubory, kde provedl 21 přidání a 12 odebrání
  1. +0
    -1
      src/webviews/apps/settings/settings.ts
  2. +21
    -11
      src/webviews/apps/shared/appWithConfigBase.ts

+ 0
- 1
src/webviews/apps/settings/settings.ts Zobrazit soubor

@ -308,7 +308,6 @@ export class SettingsApp extends AppWithConfig {
type="button"
data-action="hide"
data-action-target="autolink"
disabled
title="Delete"
aria-label="Delete"
><i class="codicon codicon-close"></i></button>

+ 21
- 11
src/webviews/apps/shared/appWithConfigBase.ts Zobrazit soubor

@ -129,20 +129,30 @@ export abstract class AppWithConfig extends Ap
const index = parseInt(props[1], 10);
const objectProps = props.slice(2);
const setting: Record<string, any>[] = this.getSettingValue(settingName) ?? [];
let setting: Record<string, any>[] | 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;
}

Načítá se…
Zrušit
Uložit