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, context.extensionMode === ExtensionMode.Development,
); );
const defaultDateLocale = configuration.get('defaultDateLocale');
const sw = new Stopwatch(`GitLens${prerelease ? ' (pre-release)' : ''} v${gitlensVersion}`, { const sw = new Stopwatch(`GitLens${prerelease ? ' (pre-release)' : ''} v${gitlensVersion}`, {
log: { 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' : ''} //${context.extensionRuntime !== ExtensionRuntime.Node ? ' in a webworker' : ''}
}, },
}); });
@ -122,11 +124,11 @@ export async function activate(context: ExtensionContext): Promise
Configuration.configure(context); Configuration.configure(context);
setDefaultDateLocales(configuration.get('defaultDateLocale') ?? env.language);
setDefaultDateLocales(defaultDateLocale ?? env.language);
context.subscriptions.push( context.subscriptions.push(
configuration.onDidChange(e => { configuration.onDidChange(e => {
if (configuration.changed(e, 'defaultDateLocale')) { 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) { export function setDefaultDateLocales(locales: string | string[] | null | undefined) {
if (typeof locales === 'string') { if (typeof locales === 'string') {
if (locales === 'system') {
if (locales === 'system' || locales.trim().length === 0) {
defaultLocales = undefined; defaultLocales = undefined;
} else { } else {
defaultLocales = [locales]; defaultLocales = [locales];

Ładowanie…
Anuluj
Zapisz