diff --git a/src/extension.ts b/src/extension.ts index 07d0450..1480192 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -133,7 +133,7 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin } } - if (Versions.compare(previous, Versions.from(7, 3, 0)) !== 1) { + if (Versions.compare(previous, Versions.from(7, 3, 0, 'beta2')) !== 1) { const oldSection = 'advanced.maxQuickHistory'; const inspection = configuration.inspect(oldSection); if (inspection !== undefined) { diff --git a/src/system/version.ts b/src/system/version.ts index 94acc6a..47fab99 100644 --- a/src/system/version.ts +++ b/src/system/version.ts @@ -5,6 +5,7 @@ export namespace Versions { major: number; minor: number; patch: number; + pre?: string; } export function compare(v1: Version, v2: Version): number { @@ -17,19 +18,26 @@ export namespace Versions { if (v1.patch > v2.patch) return 1; if (v1.patch < v2.patch) return -1; + if (v1.pre === undefined && v2.pre !== undefined) return 1; + if (v1.pre !== undefined && v2.pre === undefined) return -1; + + if (v1.pre !== undefined && v2.pre !== undefined) return v1.pre.localeCompare(v2.pre); + return 0; } - export function from(major: string | number, minor: string | number, patch: string | number): Version { + export function from(major: string | number, minor: string | number, patch: string | number, pre?: string): Version { return { major: typeof major === 'string' ? parseInt(major, 10) : major, minor: typeof minor === 'string' ? parseInt(minor, 10) : minor, - patch: typeof patch === 'string' ? parseInt(patch, 10) : patch + patch: typeof patch === 'string' ? parseInt(patch, 10) : patch, + pre: pre }; } export function fromString(version: string): Version { - const [major, minor, patch] = version.split('.'); - return from(major, minor, patch); + const [ver, pre] = version.split('-'); + const [major, minor, patch] = ver.split('.'); + return from(major, minor, patch, pre); } } \ No newline at end of file