@volar/language-core 1.5.2 → 1.5.4

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.
@@ -5,6 +5,7 @@ import type { FileRangeCapabilities, Language, VirtualFile } from './types';
5
5
  export type VirtualFiles = ReturnType<typeof createVirtualFiles>;
6
6
  export interface Source {
7
7
  fileName: string;
8
+ languageId: string | undefined;
8
9
  snapshot: ts.IScriptSnapshot;
9
10
  root: VirtualFile;
10
11
  language: Language;
@@ -17,15 +17,22 @@ function createVirtualFiles(languages) {
17
17
  const key = normalizePath(fileName);
18
18
  const value = sourceFiles.get(key);
19
19
  if (value) {
20
- value.snapshot = snapshot;
21
- value.language.updateVirtualFile(value.root, snapshot);
22
- sourceFilesDirty = true;
23
- return value.root; // updated
20
+ if (value.languageId !== languageId) {
21
+ // languageId changed
22
+ this.deleteSource(fileName);
23
+ return this.updateSource(fileName, snapshot, languageId);
24
+ }
25
+ else {
26
+ value.snapshot = snapshot;
27
+ value.language.updateVirtualFile(value.root, snapshot);
28
+ sourceFilesDirty = true;
29
+ return value.root; // updated
30
+ }
24
31
  }
25
32
  for (const language of languages) {
26
33
  const virtualFile = language.createVirtualFile(fileName, snapshot, languageId);
27
34
  if (virtualFile) {
28
- sourceFiles.set(key, { fileName, snapshot, root: virtualFile, language });
35
+ sourceFiles.set(key, { fileName, languageId, snapshot, root: virtualFile, language });
29
36
  sourceFilesDirty = true;
30
37
  return virtualFile; // created
31
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-core",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/language-core"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/source-map": "1.5.2"
16
+ "@volar/source-map": "1.5.4"
17
17
  },
18
- "gitHead": "e58503bf9700e96557e583f95e38a21c8f7b4a0a"
18
+ "gitHead": "9b96450d7e4d87d1b77af45a5ce796724fc606ce"
19
19
  }