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.
Files changed (2) hide show
  1. package/index.js +16 -12
  2. 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
- const languageServiceHost = context.language.typescript?.languageServiceHost;
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 [_, sourceFile] = context.language.files.getVirtualFile(fileName);
118
- if (sourceFile?.virtualFile) {
119
- for (const virtualFile of Array.from((0, language_service_1.forEachEmbeddedFile)(sourceFile.virtualFile[0]))) {
120
- if (virtualFile.languageId === 'markdown') {
121
- const document = context.documents.get(virtualFile.fileName, virtualFile.languageId, virtualFile.snapshot);
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 virtualFile = context.language.files.getVirtualFile(context.env.uriToFileName(uri))[0];
247
- if (virtualFile) {
248
- return context.documents.get(uri, virtualFile.languageId, virtualFile.snapshot);
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.language.files.getSourceFile(context.env.uriToFileName(uri));
252
- if (sourceFile && !sourceFile.virtualFile) {
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.24",
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": "f0532815ff3cdcf289dc582ddd3b8e3bff0cba26"
44
+ "gitHead": "876051c97aedf04531033784019b4344cdd48881"
45
45
  }