volar-service-markdown 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +3 -3
- package/index.js +14 -11
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DocumentSelector,
|
|
1
|
+
import type { DocumentSelector, ProviderResult, ServiceContext, LanguageServicePlugin } from '@volar/language-service';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import type { DiagnosticOptions, IMdLanguageService } from 'vscode-markdown-languageservice';
|
|
4
4
|
export interface Provide {
|
|
@@ -6,6 +6,6 @@ export interface Provide {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function create({ documentSelector, getDiagnosticOptions, }?: {
|
|
8
8
|
documentSelector?: DocumentSelector;
|
|
9
|
-
getDiagnosticOptions?(document: TextDocument, context: ServiceContext):
|
|
10
|
-
}):
|
|
9
|
+
getDiagnosticOptions?(document: TextDocument, context: ServiceContext): ProviderResult<DiagnosticOptions | undefined>;
|
|
10
|
+
}): LanguageServicePlugin;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -38,7 +38,7 @@ function create({ documentSelector = ['markdown'], getDiagnosticOptions = async
|
|
|
38
38
|
const onDidChangeMarkdownDocument = new vscode_jsonrpc_1.Emitter();
|
|
39
39
|
const onDidCreateMarkdownDocument = new vscode_jsonrpc_1.Emitter();
|
|
40
40
|
const onDidDeleteMarkdownDocument = new vscode_jsonrpc_1.Emitter();
|
|
41
|
-
const fileWatcher = onDidChangeWatchedFiles(
|
|
41
|
+
const fileWatcher = onDidChangeWatchedFiles(event => {
|
|
42
42
|
for (const change of event.changes) {
|
|
43
43
|
switch (change.type) {
|
|
44
44
|
case 2: {
|
|
@@ -116,18 +116,19 @@ function create({ documentSelector = ['markdown'], getDiagnosticOptions = async
|
|
|
116
116
|
const newVersions = new Map();
|
|
117
117
|
for (const fileName of languageServiceHost.getScriptFileNames()) {
|
|
118
118
|
const uri = context.env.typescript.fileNameToUri(fileName);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
120
|
+
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
121
|
+
if (sourceScript?.generated) {
|
|
122
|
+
for (const virtualCode of (0, language_service_1.forEachEmbeddedCode)(sourceScript.generated.root)) {
|
|
122
123
|
if (matchDocument(documentSelector, virtualCode)) {
|
|
123
|
-
const uri = context.
|
|
124
|
+
const uri = context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id);
|
|
124
125
|
const document = context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
|
|
125
126
|
newVersions.set(document.uri, document);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
else if (
|
|
130
|
-
const document = context.documents.get(fileName,
|
|
130
|
+
else if (sourceScript) {
|
|
131
|
+
const document = context.documents.get(fileName, sourceScript.languageId, sourceScript.snapshot);
|
|
131
132
|
if (document && matchDocument(documentSelector, document)) {
|
|
132
133
|
newVersions.set(document.uri, document);
|
|
133
134
|
}
|
|
@@ -262,14 +263,16 @@ function create({ documentSelector = ['markdown'], getDiagnosticOptions = async
|
|
|
262
263
|
};
|
|
263
264
|
function getTextDocument(uri, includeVirtualFile) {
|
|
264
265
|
if (includeVirtualFile) {
|
|
265
|
-
const
|
|
266
|
+
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
267
|
+
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
268
|
+
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
266
269
|
if (virtualCode) {
|
|
267
270
|
return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
|
|
268
271
|
}
|
|
269
272
|
}
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
return context.documents.get(uri,
|
|
273
|
+
const sourceScript = context.language.scripts.get(uri);
|
|
274
|
+
if (sourceScript) {
|
|
275
|
+
return context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
|
|
273
276
|
}
|
|
274
277
|
}
|
|
275
278
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-markdown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "Integrate vscode-markdown-languageservice into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/markdown",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"markdown-it": "^13.0.2",
|
|
28
28
|
"vscode-jsonrpc": "^8.2.0",
|
|
29
|
-
"vscode-markdown-languageservice": "~0.
|
|
29
|
+
"vscode-markdown-languageservice": "~0.5.0-alpha.1",
|
|
30
30
|
"vscode-uri": "^3.0.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"vscode-languageserver-textdocument": "^1.0.11"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@volar/language-service": "~2.
|
|
37
|
+
"@volar/language-service": "~2.2.0-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@volar/language-service": {
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "cbd8ef0ada6eae9656286535599c9b289134d1e3"
|
|
45
45
|
}
|