Skip to content

Commit

Permalink
Fix #78068
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Aug 27, 2019
1 parent 04d5250 commit 739ae77
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 4 deletions.
31 changes: 30 additions & 1 deletion extensions/css-language-features/client/src/customData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as path from 'path';
import { workspace, WorkspaceFolder, extensions } from 'vscode';

interface ExperimentalConfig {
customData?: string[];
experimental?: {
customData?: string[];
};
Expand All @@ -19,6 +20,21 @@ export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFol
return dataPaths;
}

workspaceFolders.forEach(wf => {
const allCssConfig = workspace.getConfiguration(undefined, wf.uri);
const wfCSSConfig = allCssConfig.inspect<ExperimentalConfig>('css');
if (wfCSSConfig && wfCSSConfig.workspaceFolderValue && wfCSSConfig.workspaceFolderValue.customData) {
const customData = wfCSSConfig.workspaceFolderValue.customData;
if (Array.isArray(customData)) {
customData.forEach(t => {
if (typeof t === 'string') {
dataPaths.push(path.resolve(wf.uri.fsPath, t));
}
});
}
}
});

workspaceFolders.forEach(wf => {
const allCssConfig = workspace.getConfiguration(undefined, wf.uri);
const wfCSSConfig = allCssConfig.inspect<ExperimentalConfig>('css');
Expand Down Expand Up @@ -48,7 +64,20 @@ export function getCustomDataPathsFromAllExtensions(): string[] {
for (const extension of extensions.all) {
const contributes = extension.packageJSON && extension.packageJSON.contributes;

if (contributes && contributes.css && contributes.css.experimental.customData && Array.isArray(contributes.css.experimental.customData)) {
if (contributes && contributes.css && contributes.css.customData && Array.isArray(contributes.css.customData)) {
const relativePaths: string[] = contributes.css.customData;
relativePaths.forEach(rp => {
dataPaths.push(path.resolve(extension.extensionPath, rp));
});
}

if (
contributes &&
contributes.css &&
contributes.experimental &&
contributes.css.experimental.customData &&
Array.isArray(contributes.css.experimental.customData)
) {
const relativePaths: string[] = contributes.css.experimental.customData;
relativePaths.forEach(rp => {
dataPaths.push(path.resolve(extension.extensionPath, rp));
Expand Down
12 changes: 11 additions & 1 deletion extensions/css-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,24 @@
"id": "css",
"title": "%css.title%",
"properties": {
"css.customData": {
"type": "array",
"description": "%css.customData.desc%",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
},
"css.experimental.customData": {
"type": "array",
"description": "A list of JSON file paths that define custom CSS data that loads custom properties, at directives, pseudo classes / elements.",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
"scope": "resource",
"deprecationMessage": "This setting is no longe experimental. Use `css.customData` instead."
},
"css.completion.triggerPropertyValueCompletion": {
"type": "boolean",
Expand Down
1 change: 1 addition & 0 deletions extensions/css-language-features/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"displayName": "CSS Language Features",
"description": "Provides rich language support for CSS, LESS and SCSS files.",
"css.title": "CSS",
"css.customData.desc": "A list of JSON file paths that define custom CSS data that loads custom properties, at directives, pseudo classes / elements.",
"css.completion.triggerPropertyValueCompletion.desc": "By default, VS Code triggers property value completion after selecting a CSS property. Use this setting to disable this behavior.",
"css.lint.argumentsInColorFunction.desc": "Invalid number of parameters.",
"css.lint.boxModel.desc": "Do not use `width` or `height` when using `padding` or `border`.",
Expand Down
25 changes: 25 additions & 0 deletions extensions/html-language-features/client/src/customData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as path from 'path';
import { workspace, WorkspaceFolder, extensions } from 'vscode';

interface ExperimentalConfig {
customData?: string[];
experimental?: {
customData?: string[];
};
Expand All @@ -23,6 +24,17 @@ export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFol
const allHtmlConfig = workspace.getConfiguration(undefined, wf.uri);
const wfHtmlConfig = allHtmlConfig.inspect<ExperimentalConfig>('html');

if (wfHtmlConfig && wfHtmlConfig.workspaceFolderValue && wfHtmlConfig.workspaceFolderValue.customData) {
const customData = wfHtmlConfig.workspaceFolderValue.customData;
if (Array.isArray(customData)) {
customData.forEach(t => {
if (typeof t === 'string') {
dataPaths.push(path.resolve(wf.uri.fsPath, t));
}
});
}
}

if (
wfHtmlConfig &&
wfHtmlConfig.workspaceFolderValue &&
Expand Down Expand Up @@ -52,6 +64,19 @@ export function getCustomDataPathsFromAllExtensions(): string[] {
if (
contributes &&
contributes.html &&
contributes.html.customData &&
Array.isArray(contributes.html.customData)
) {
const relativePaths: string[] = contributes.html.customData;
relativePaths.forEach(rp => {
dataPaths.push(path.resolve(extension.extensionPath, rp));
});
}

if (
contributes &&
contributes.html &&
contributes.html.experimental &&
contributes.html.experimental.customData &&
Array.isArray(contributes.html.experimental.customData)
) {
Expand Down
12 changes: 11 additions & 1 deletion extensions/html-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,24 @@
"type": "object",
"title": "HTML",
"properties": {
"html.customData": {
"type": "array",
"description": "%html.customData.desc%",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
},
"html.experimental.customData": {
"type": "array",
"description": "A list of JSON file paths that define custom tags, properties and other HTML syntax constructs. Only workspace folder setting will be read.",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
"scope": "resource",
"deprecationMessage": "This setting is no longe experimental. Use `html.customData` instead."
},
"html.format.enable": {
"type": "boolean",
Expand Down
3 changes: 2 additions & 1 deletion extensions/html-language-features/package.nls.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"displayName": "HTML Language Features",
"description": "Provides rich language support for HTML and Handlebar files",
"html.customData.desc": "A list of JSON file paths that define custom tags, properties and other HTML syntax constructs. Only workspace folder setting will be read.",
"html.format.enable.desc": "Enable/disable default HTML formatter.",
"html.format.wrapLineLength.desc": "Maximum amount of characters per line (0 = disable).",
"html.format.unformatted.desc": "List of tags, comma separated, that shouldn't be reformatted. `null` defaults to all tags listed at https://www.w3.org/TR/html5/dom.html#phrasing-content.",
Expand All @@ -24,4 +25,4 @@
"html.validate.scripts": "Controls whether the built-in HTML language support validates embedded scripts.",
"html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.",
"html.autoClosingTags": "Enable/disable autoclosing of HTML tags."
}
}

0 comments on commit 739ae77

Please sign in to comment.