|
1 | 1 | 'use strict'; |
2 | | -import { Objects } from './system'; |
| 2 | +import { Objects, Versions } from './system'; |
3 | 3 | import { ConfigurationTarget, ExtensionContext, extensions, languages, window, workspace } from 'vscode'; |
4 | 4 | import { AnnotationController } from './annotations/annotationController'; |
5 | 5 | import { configuration, Configuration, IConfig } from './configuration'; |
@@ -100,37 +100,51 @@ export async function activate(context: ExtensionContext) { |
100 | 100 | // this method is called when your extension is deactivated |
101 | 101 | export function deactivate() { } |
102 | 102 |
|
103 | | -const migration = { |
104 | | - major: 6, |
105 | | - minor: 1, |
106 | | - patch: 2 |
107 | | -}; |
108 | | - |
109 | 103 | async function migrateSettings(context: ExtensionContext, previousVersion: string | undefined) { |
110 | 104 | if (previousVersion === undefined) return; |
111 | 105 |
|
112 | | - const [major, minor, patch] = previousVersion.split('.'); |
113 | | - if (parseInt(major, 10) >= migration.major && parseInt(minor, 10) >= migration.minor && parseInt(patch, 10) >= migration.patch) return; |
| 106 | + const previous = Versions.fromString(previousVersion); |
114 | 107 |
|
115 | 108 | try { |
116 | | - const section = configuration.name('advanced')('messages').value; |
117 | | - const messages: { [key: string]: boolean } = configuration.get(section); |
| 109 | + if (Versions.compare(previous, Versions.from(6, 1, 2)) !== 1) { |
| 110 | + try { |
| 111 | + const section = configuration.name('advanced')('messages').value; |
| 112 | + const messages: { [key: string]: boolean } = configuration.get(section); |
118 | 113 |
|
119 | | - let migrated = false; |
| 114 | + let migrated = false; |
120 | 115 |
|
121 | | - for (const m of Objects.values(SuppressedMessages)) { |
122 | | - const suppressed = context.globalState.get<boolean>(m); |
123 | | - if (suppressed === undefined) continue; |
| 116 | + for (const m of Objects.values(SuppressedMessages)) { |
| 117 | + const suppressed = context.globalState.get<boolean>(m); |
| 118 | + if (suppressed === undefined) continue; |
124 | 119 |
|
125 | | - migrated = true; |
126 | | - messages[m] = suppressed; |
| 120 | + migrated = true; |
| 121 | + messages[m] = suppressed; |
127 | 122 |
|
128 | | - context.globalState.update(m, undefined); |
129 | | - } |
| 123 | + context.globalState.update(m, undefined); |
| 124 | + } |
130 | 125 |
|
131 | | - if (!migrated) return; |
| 126 | + if (!migrated) return; |
132 | 127 |
|
133 | | - await configuration.update(section, messages, ConfigurationTarget.Global); |
| 128 | + await configuration.update(section, messages, ConfigurationTarget.Global); |
| 129 | + } |
| 130 | + catch (ex) { |
| 131 | + Logger.error(ex, 'migrateSettings - messages'); |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + if (Versions.compare(previous, Versions.from(7, 1, 0)) !== 1) { |
| 136 | + // https://github.com/eamodio/vscode-gitlens/issues/239 |
| 137 | + const section = configuration.name('advanced')('quickPick')('closeOnFocusOut').value; |
| 138 | + const inspection = configuration.inspect(section); |
| 139 | + if (inspection !== undefined) { |
| 140 | + if (inspection.globalValue !== undefined) { |
| 141 | + await configuration.update(section, !inspection.globalValue, ConfigurationTarget.Global); |
| 142 | + } |
| 143 | + else if (inspection.workspaceFolderValue !== undefined) { |
| 144 | + await configuration.update(section, !inspection.workspaceFolderValue, ConfigurationTarget.WorkspaceFolder); |
| 145 | + } |
| 146 | + } |
| 147 | + } |
134 | 148 | } |
135 | 149 | catch (ex) { |
136 | 150 | Logger.error(ex, 'migrateSettings'); |
|
0 commit comments