Skip to content

Commit 05dec69

Browse files
committed
fix: html / css custom data not working
#707 (comment)
1 parent 3fd1d78 commit 05dec69

File tree

4 files changed

+8
-34
lines changed

4 files changed

+8
-34
lines changed

plugins/css/src/index.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as shared from '@volar/shared';
33
import * as css from 'vscode-css-languageservice';
44
import * as vscode from 'vscode-languageserver-protocol';
55
import { TextDocument } from 'vscode-languageserver-textdocument';
6+
import * as path from 'path';
67

78
const wordPatterns: { [lang: string]: RegExp; } = {
89
css: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g,
@@ -240,25 +241,13 @@ export default function (): LanguageServicePlugin {
240241

241242
if (configHost) {
242243

243-
const paths = new Set<string>();
244244
const customData: string[] = await configHost.getConfiguration('css.customData') ?? [];
245-
const rootPath = shared.getPathOfUri(context.env.rootUri.toString());
246-
247-
for (const customDataPath of customData) {
248-
try {
249-
const jsonPath = require.resolve(customDataPath, { paths: [rootPath] });
250-
paths.add(jsonPath);
251-
}
252-
catch (error) {
253-
console.error(error);
254-
}
255-
}
256-
257245
const newData: css.ICSSDataProvider[] = [];
258246

259-
for (const path of paths) {
247+
for (const customDataPath of customData) {
260248
try {
261-
newData.push(css.newCSSDataProvider(require(path)));
249+
const jsonPath = path.resolve(customDataPath);
250+
newData.push(css.newCSSDataProvider(require(jsonPath)));
262251
}
263252
catch (error) {
264253
console.error(error);

plugins/html/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"dependencies": {
1616
"@volar/language-service": "1.0.0-rc.3",
17-
"@volar/shared": "1.0.0-rc.3",
1817
"vscode-html-languageservice": "^5.0.1",
1918
"vscode-languageserver-protocol": "^3.17.2",
2019
"vscode-languageserver-textdocument": "^1.0.7"

plugins/html/src/index.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { LanguageServicePlugin, LanguageServicePluginContext } from '@volar/language-service';
2-
import * as shared from '@volar/shared';
32
import * as html from 'vscode-html-languageservice';
43
import * as vscode from 'vscode-languageserver-protocol';
54
import { TextDocument } from 'vscode-languageserver-textdocument';
5+
import * as path from 'path';
66

77
export default function (options: {
88
validLang?: string,
@@ -217,25 +217,13 @@ export default function (options: {
217217

218218
if (configHost) {
219219

220-
const paths = new Set<string>();
221220
const customData: string[] = await configHost.getConfiguration('html.customData') ?? [];
222-
const rootPath = shared.getPathOfUri(context.env.rootUri.toString());
223-
224-
for (const customDataPath of customData) {
225-
try {
226-
const jsonPath = require.resolve(customDataPath, { paths: [rootPath] });
227-
paths.add(jsonPath);
228-
}
229-
catch (error) {
230-
console.error(error);
231-
}
232-
}
233-
234221
const newData: html.IHTMLDataProvider[] = [];
235222

236-
for (const path of paths) {
223+
for (const customDataPath of customData) {
237224
try {
238-
newData.push(html.newHTMLDataProvider(path, require(path)));
225+
const jsonPath = path.resolve(customDataPath);
226+
newData.push(html.newHTMLDataProvider(customDataPath, require(jsonPath)));
239227
}
240228
catch (error) {
241229
console.error(error);

pnpm-lock.yaml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)