@vue/language-core 2.0.5 → 2.0.6

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.
@@ -942,7 +942,10 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
942
942
  else {
943
943
  const propVariableName = (0, shared_1.camelize)(prop.exp.loc.source);
944
944
  if (validTsVarReg.test(propVariableName)) {
945
- yield _ts('__VLS_ctx.');
945
+ if (!localVars.has(propVariableName)) {
946
+ accessedGlobalVariables.add(propVariableName);
947
+ yield _ts('__VLS_ctx.');
948
+ }
946
949
  yield* generateCamelized(prop.exp.loc.source, prop.exp.loc.start.offset, caps_all);
947
950
  if (mode === 'normal') {
948
951
  yield _ts([
@@ -951,18 +954,17 @@ function* generate(ts, compilerOptions, vueCompilerOptions, template, shouldGene
951
954
  prop.exp.loc.end.offset,
952
955
  (0, utils_1.disableAllFeatures)({
953
956
  __hint: {
954
- setting: 'vue.inlayHints.vbindShorthand',
957
+ setting: 'vue.inlayHints.vBindShorthand',
955
958
  label: `="${propVariableName}"`,
956
959
  tooltip: [
957
960
  `This is a shorthand for \`${prop.exp.loc.source}="${propVariableName}"\`.`,
958
- 'To hide this hint, set `vue.inlayHints.vbindShorthand` to `false` in IDE settings.',
961
+ 'To hide this hint, set `vue.inlayHints.vBindShorthand` to `false` in IDE settings.',
959
962
  '[More info](https://github.com/vuejs/core/pull/9451)',
960
963
  ].join('\n\n'),
961
964
  },
962
965
  })
963
966
  ]);
964
967
  }
965
- accessedGlobalVariables.add(propVariableName);
966
968
  }
967
969
  }
968
970
  }
@@ -1,4 +1,4 @@
1
- import { Mapping } from '@volar/language-core';
1
+ import { CodeMapping } from '@volar/language-core';
2
2
  import type * as ts from 'typescript';
3
- import type { Sfc, VueCodeInformation } from '../types';
4
- export declare function computedMappings(snapshot: () => ts.IScriptSnapshot, sfc: Sfc): () => Mapping<VueCodeInformation>[];
3
+ import type { Sfc } from '../types';
4
+ export declare function computedMappings(snapshot: () => ts.IScriptSnapshot, sfc: Sfc): () => CodeMapping[];
@@ -18,7 +18,7 @@ function computedMappings(snapshot, sfc) {
18
18
  (0, language_core_1.replaceSourceRange)(str, undefined, block.startTagEnd, block.endTagStart, '\n\n');
19
19
  }
20
20
  }
21
- return str
21
+ const mappings = str
22
22
  .filter(s => typeof s !== 'string')
23
23
  .map((m) => {
24
24
  const text = m[0];
@@ -30,6 +30,36 @@ function computedMappings(snapshot, sfc) {
30
30
  data: m[3],
31
31
  };
32
32
  });
33
+ // fix folding range end position failed to mapping
34
+ for (const block of [
35
+ sfc.script,
36
+ sfc.scriptSetup,
37
+ sfc.template,
38
+ ...sfc.styles,
39
+ ...sfc.customBlocks,
40
+ ]) {
41
+ const offsets = [];
42
+ if (block) {
43
+ let content = block.content;
44
+ if (content.endsWith('\r\n')) {
45
+ content = content.slice(0, -2);
46
+ }
47
+ else if (content.endsWith('\n')) {
48
+ content = content.slice(0, -1);
49
+ }
50
+ const offset = content.lastIndexOf('\n') + 1;
51
+ offsets.push(block.startTagEnd + offset);
52
+ }
53
+ if (offsets.length) {
54
+ mappings.push({
55
+ sourceOffsets: offsets,
56
+ generatedOffsets: offsets,
57
+ lengths: offsets.map(() => 0),
58
+ data: (0, utils_1.disableAllFeatures)({ structure: true }),
59
+ });
60
+ }
61
+ }
62
+ return mappings;
33
63
  });
34
64
  }
35
65
  exports.computedMappings = computedMappings;
@@ -14,12 +14,12 @@ export declare class VueGeneratedCode implements VirtualCode {
14
14
  _snapshot: Signal<ts.IScriptSnapshot>;
15
15
  getVueSfc: () => import("@vue/compiler-sfc").SFCParseResult | undefined;
16
16
  sfc: import("../types").Sfc;
17
- getMappings: () => import("@volar/language-core").Mapping<import("../types").VueCodeInformation>[];
17
+ getMappings: () => import("@volar/language-core").CodeMapping[];
18
18
  getEmbeddedCodes: () => VirtualCode[];
19
19
  codegenStacks: Stack[];
20
20
  get embeddedCodes(): VirtualCode[];
21
21
  get snapshot(): ts.IScriptSnapshot;
22
- get mappings(): import("@volar/language-core").Mapping<import("../types").VueCodeInformation>[];
22
+ get mappings(): import("@volar/language-core").CodeMapping[];
23
23
  constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: ReturnType<VueLanguagePlugin>[], ts: typeof import('typescript'), codegenStack: boolean);
24
24
  update(newSnapshot: ts.IScriptSnapshot): void;
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/language-core"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "~2.1.1",
15
+ "@volar/language-core": "~2.1.2",
16
16
  "@vue/compiler-dom": "^3.4.0",
17
17
  "@vue/shared": "^3.4.0",
18
18
  "computeds": "^0.0.1",
@@ -34,5 +34,5 @@
34
34
  "optional": true
35
35
  }
36
36
  },
37
- "gitHead": "62b4fcb0d3f7153b5b2f5571af32f519117d8466"
37
+ "gitHead": "feb990ccec85f6330bba37c8b1d1287f0980274c"
38
38
  }