volar-service-markdown 0.0.24 → 0.0.26
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.js +16 -12
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ function assert(condition, message) {
|
|
|
18
18
|
function create(options) {
|
|
19
19
|
return {
|
|
20
20
|
name: 'markdown',
|
|
21
|
+
triggerCharacters: ['.', '/', '#'],
|
|
21
22
|
create(context) {
|
|
22
23
|
let lastProjectVersion;
|
|
23
24
|
const { fs, getConfiguration, onDidChangeWatchedFiles } = context.env;
|
|
@@ -102,9 +103,10 @@ function create(options) {
|
|
|
102
103
|
});
|
|
103
104
|
const syncedVersions = new Map();
|
|
104
105
|
const sync = () => {
|
|
105
|
-
|
|
106
|
-
if (!languageServiceHost)
|
|
106
|
+
if (!context.typescript) {
|
|
107
107
|
return;
|
|
108
|
+
}
|
|
109
|
+
const { languageServiceHost } = context.typescript;
|
|
108
110
|
const newProjectVersion = languageServiceHost.getProjectVersion?.();
|
|
109
111
|
const shouldUpdate = newProjectVersion === undefined || newProjectVersion !== lastProjectVersion;
|
|
110
112
|
if (!shouldUpdate) {
|
|
@@ -114,11 +116,13 @@ function create(options) {
|
|
|
114
116
|
const oldVersions = new Set(syncedVersions.keys());
|
|
115
117
|
const newVersions = new Map();
|
|
116
118
|
for (const fileName of languageServiceHost.getScriptFileNames()) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const uri = context.env.typescript.fileNameToUri(fileName);
|
|
120
|
+
const [_, sourceFile] = context.documents.getVirtualCodeByUri(uri);
|
|
121
|
+
if (sourceFile?.generated) {
|
|
122
|
+
for (const virtualCode of (0, language_service_1.forEachEmbeddedCode)(sourceFile.generated.code)) {
|
|
123
|
+
if (virtualCode.languageId === 'markdown') {
|
|
124
|
+
const uri = context.documents.getVirtualCodeUri(sourceFile.id, virtualCode.id);
|
|
125
|
+
const document = context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
|
|
122
126
|
newVersions.set(document.uri, document);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
@@ -243,13 +247,13 @@ function create(options) {
|
|
|
243
247
|
};
|
|
244
248
|
function getTextDocument(uri, includeVirtualFile) {
|
|
245
249
|
if (includeVirtualFile) {
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
return context.documents.get(uri,
|
|
250
|
+
const virtualCode = context.documents.getVirtualCodeByUri(uri)[0];
|
|
251
|
+
if (virtualCode) {
|
|
252
|
+
return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
|
|
249
253
|
}
|
|
250
254
|
}
|
|
251
|
-
const sourceFile = context.
|
|
252
|
-
if (sourceFile
|
|
255
|
+
const sourceFile = context.files.get(uri);
|
|
256
|
+
if (sourceFile) {
|
|
253
257
|
return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
|
|
254
258
|
}
|
|
255
259
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-markdown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
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",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "876051c97aedf04531033784019b4344cdd48881"
|
|
45
45
|
}
|