Przeglądaj źródła

Fixes #2671 protects against bad locale

main
Eric Amodio 1 rok temu
rodzic
commit
bdeb2a95be
2 zmienionych plików z 8 dodań i 6 usunięć
  1. +7
    -5
      src/extension.ts
  2. +1
    -1
      src/system/date.ts

+ 7
- 5
src/extension.ts Wyświetl plik

@ -62,11 +62,13 @@ export async function activate(context: ExtensionContext): Promise
context.extensionMode === ExtensionMode.Development,
);
const defaultDateLocale = configuration.get('defaultDateLocale');
const sw = new Stopwatch(`GitLens${prerelease ? ' (pre-release)' : ''} v${gitlensVersion}`, {
log: {
message: ` activating in ${env.appName} (${codeVersion}) on the ${
isWeb ? 'web' : 'desktop'
} using language '${env.language}' (${env.machineId}|${env.sessionId})`,
message: ` activating in ${env.appName} (${codeVersion}) on the ${isWeb ? 'web' : 'desktop'}; language='${
env.language
}', defaultDateLocale='${defaultDateLocale}' (${env.machineId}|${env.sessionId})`,
//${context.extensionRuntime !== ExtensionRuntime.Node ? ' in a webworker' : ''}
},
});
@ -122,11 +124,11 @@ export async function activate(context: ExtensionContext): Promise
Configuration.configure(context);
setDefaultDateLocales(configuration.get('defaultDateLocale') ?? env.language);
setDefaultDateLocales(defaultDateLocale ?? env.language);
context.subscriptions.push(
configuration.onDidChange(e => {
if (configuration.changed(e, 'defaultDateLocale')) {
setDefaultDateLocales(configuration.get('defaultDateLocale', undefined, env.language));
setDefaultDateLocales(configuration.get('defaultDateLocale') ?? env.language);
}
}),
);

+ 1
- 1
src/system/date.ts Wyświetl plik

@ -28,7 +28,7 @@ const numberFormatCache = new Map();
export function setDefaultDateLocales(locales: string | string[] | null | undefined) {
if (typeof locales === 'string') {
if (locales === 'system') {
if (locales === 'system' || locales.trim().length === 0) {
defaultLocales = undefined;
} else {
defaultLocales = [locales];

Ładowanie…
Anuluj
Zapisz