@volar/language-service 1.0.0-alpha.4 → 1.0.0-alpha.5

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.
@@ -60,17 +60,17 @@ function register(context, api, isValidMappingData, isValidTeleportSideData) {
60
60
  });
61
61
  }
62
62
  }), (data, sourceMap) => data.map(link => {
63
- var _a, _b, _c;
63
+ var _a, _b;
64
64
  if (link.originSelectionRange && sourceMap) {
65
- const originSelectionRange = (_a = sourceMap.getSourceRange(link.originSelectionRange.start, link.originSelectionRange.end)) === null || _a === void 0 ? void 0 : _a[0];
65
+ const originSelectionRange = getSourceRangePreferSurroundedPosition(sourceMap, link.originSelectionRange, position);
66
66
  if (!originSelectionRange)
67
67
  return;
68
68
  link.originSelectionRange = originSelectionRange;
69
69
  }
70
70
  const targetSourceMap = context.documents.sourceMapFromEmbeddedDocumentUri(link.targetUri);
71
71
  if (targetSourceMap) {
72
- const targetRange = (_b = targetSourceMap.getSourceRange(link.targetRange.start, link.targetRange.end)) === null || _b === void 0 ? void 0 : _b[0];
73
- const targetSelectionRange = (_c = targetSourceMap.getSourceRange(link.targetSelectionRange.start, link.targetSelectionRange.end)) === null || _c === void 0 ? void 0 : _c[0];
72
+ const targetRange = (_a = targetSourceMap.getSourceRange(link.targetRange.start, link.targetRange.end)) === null || _a === void 0 ? void 0 : _a[0];
73
+ const targetSelectionRange = (_b = targetSourceMap.getSourceRange(link.targetSelectionRange.start, link.targetSelectionRange.end)) === null || _b === void 0 ? void 0 : _b[0];
74
74
  if (!targetSelectionRange)
75
75
  return;
76
76
  link.targetUri = targetSourceMap.sourceDocument.uri;
@@ -82,4 +82,18 @@ function register(context, api, isValidMappingData, isValidTeleportSideData) {
82
82
  };
83
83
  }
84
84
  exports.register = register;
85
+ function getSourceRangePreferSurroundedPosition(sourceMap, mappedRange, position) {
86
+ let result;
87
+ for (const [sourceRange] of sourceMap.getSourceRanges(mappedRange.start, mappedRange.end)) {
88
+ if (!result) {
89
+ result = sourceRange;
90
+ }
91
+ if ((sourceRange.start.line < position.line || (sourceRange.start.line === position.line && sourceRange.start.character <= position.character))
92
+ && (sourceRange.end.line > position.line || (sourceRange.end.line === position.line && sourceRange.end.character >= position.character))) {
93
+ result = sourceRange;
94
+ break;
95
+ }
96
+ }
97
+ return result;
98
+ }
85
99
  //# sourceMappingURL=definition.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -16,11 +16,11 @@
16
16
  "typescript": "latest"
17
17
  },
18
18
  "dependencies": {
19
- "@volar/language-core": "1.0.0-alpha.4",
20
- "@volar/shared": "1.0.0-alpha.4",
21
- "@volar/source-map": "1.0.0-alpha.4",
22
- "@volar/transforms": "1.0.0-alpha.4",
23
- "@volar/typescript-faster": "1.0.0-alpha.4",
19
+ "@volar/language-core": "1.0.0-alpha.5",
20
+ "@volar/shared": "1.0.0-alpha.5",
21
+ "@volar/source-map": "1.0.0-alpha.5",
22
+ "@volar/transforms": "1.0.0-alpha.5",
23
+ "@volar/typescript-faster": "1.0.0-alpha.5",
24
24
  "@vue/reactivity": "^3.2.38",
25
25
  "upath": "^2.0.1",
26
26
  "vscode-html-languageservice": "^5.0.1",
@@ -29,5 +29,5 @@
29
29
  "vscode-languageserver-textdocument": "^1.0.7",
30
30
  "vscode-uri": "^3.0.3"
31
31
  },
32
- "gitHead": "712fc3178ed7a7414da73e940c5c5e8b54eebea1"
32
+ "gitHead": "dd3efd3f7458aca9ba5dcdf549ce80999cb7affd"
33
33
  }