Browse Source

Fixes #2671 protects against bad locale

main
Eric Amodio 1 year ago
parent
commit
bdeb2a95be
2 changed files with 8 additions and 6 deletions
  1. +7
    -5
      src/extension.ts
  2. +1
    -1
      src/system/date.ts

+ 7
- 5
src/extension.ts View File

@ -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 View File

@ -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];

Loading…
Cancel
Save