Emmet: Change the type of emmet extensions path (#117946)

* Emmet: change extensionsPath input type to string[]
* Emmet: add migration function for old config
This commit is contained in:
Hsuan-An Weng Lin 2021-03-02 14:14:51 -06:00 committed by GitHub
parent cc5db25823
commit 975dfff6db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 7 deletions

View file

@ -84,12 +84,11 @@
"description": "%emmetExclude%"
},
"emmet.extensionsPath": {
"type": [
"string",
"array",
"null"
],
"default": null,
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "%emmetExtensionsPath%"
},
"emmet.triggerExpansionOnTab": {

View file

@ -17,11 +17,12 @@ import { fetchEditPoint } from './editPoint';
import { fetchSelectItem } from './selectItem';
import { evaluateMathExpression } from './evaluateMathExpression';
import { incrementDecrement } from './incrementDecrement';
import { LANGUAGE_MODES, getMappingForIncludedLanguages, updateEmmetExtensionsPath, getPathBaseName, getSyntaxes, getEmmetMode } from './util';
import { LANGUAGE_MODES, getMappingForIncludedLanguages, updateEmmetExtensionsPath, migrateEmmetExtensionsPath, getPathBaseName, getSyntaxes, getEmmetMode } from './util';
import { reflectCssValue } from './reflectCssValue';
import { addFileToParseCache, removeFileFromParseCache } from './parseDocument';
export function activateEmmetExtension(context: vscode.ExtensionContext) {
migrateEmmetExtensionsPath();
registerCompletionProviders(context);
updateEmmetExtensionsPath();

View file

@ -49,6 +49,34 @@ export function updateEmmetExtensionsPath(forceRefresh: boolean = false) {
}
}
/**
* Migrate old configuration(string) for extensionsPath to new type(string[])
* https://github.com/microsoft/vscode/issues/117517
*/
export function migrateEmmetExtensionsPath() {
// Get the detail info of emmet.extensionsPath setting
let config = vscode.workspace.getConfiguration().inspect('emmet.extensionsPath');
// Update Global setting if the value type is string or the value is null
if (typeof config?.globalValue === 'string') {
vscode.workspace.getConfiguration().update('emmet.extensionsPath', [config.globalValue], true);
} else if (config?.globalValue === null) {
vscode.workspace.getConfiguration().update('emmet.extensionsPath', [], true);
}
// Update Workspace setting if the value type is string or the value is null
if (typeof config?.workspaceValue === 'string') {
vscode.workspace.getConfiguration().update('emmet.extensionsPath', [config.workspaceValue], false);
} else if (config?.workspaceValue === null) {
vscode.workspace.getConfiguration().update('emmet.extensionsPath', [], false);
}
// Update WorkspaceFolder setting if the value type is string or the value is null
if (typeof config?.workspaceFolderValue === 'string') {
vscode.workspace.getConfiguration().update('emmet.extensionsPath', [config.workspaceFolderValue]);
} else if (config?.workspaceFolderValue === null) {
vscode.workspace.getConfiguration().update('emmet.extensionsPath', []);
}
}
/**
* Mapping between languages that support Emmet and completion trigger characters
*/