@volar/language-service 1.2.0-alpha.13 → 1.2.0-alpha.14

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,15 +60,13 @@ function register(context) {
60
60
  start: map.virtualFileDocument.positionAt(0),
61
61
  end: map.virtualFileDocument.positionAt(map.virtualFileDocument.getText().length),
62
62
  });
63
- if (virtualCodeEdits) {
64
- toPatchIndentUris.push({
65
- uri: map.virtualFileDocument.uri,
66
- isCodeBlock,
67
- });
68
- }
69
63
  }
70
64
  if (!virtualCodeEdits)
71
65
  continue;
66
+ toPatchIndentUris.push({
67
+ uri: map.virtualFileDocument.uri,
68
+ isCodeBlock,
69
+ });
72
70
  for (const textEdit of virtualCodeEdits) {
73
71
  const range = map.toSourceRange(textEdit.range);
74
72
  if (range) {
@@ -88,9 +86,26 @@ function register(context) {
88
86
  }
89
87
  if (level > 1) {
90
88
  const baseIndent = options.insertSpaces ? ' '.repeat(options.tabSize) : '\t';
89
+ const editLines = new Set();
90
+ if (onTypeParams) {
91
+ for (const edit of edits) {
92
+ for (let line = edit.range.start.line; line <= edit.range.end.line; line++) {
93
+ editLines.add(line);
94
+ }
95
+ }
96
+ }
91
97
  for (const toPatchIndentUri of toPatchIndentUris) {
92
98
  for (const [_, map] of context.documents.getMapsByVirtualFileUri(toPatchIndentUri.uri)) {
93
99
  let indentEdits = patchIndents(document, toPatchIndentUri.isCodeBlock, map.map, initialIndentLanguageId[map.virtualFileDocument.languageId] ? baseIndent : '');
100
+ if (onTypeParams) {
101
+ indentEdits = indentEdits.filter(edit => {
102
+ for (let line = edit.range.start.line; line <= edit.range.end.line; line++) {
103
+ if (!editLines.has(line))
104
+ return false;
105
+ }
106
+ return true;
107
+ });
108
+ }
94
109
  indentEdits = indentEdits.filter(edit => (0, common_1.isInsideRange)(range, edit.range));
95
110
  if (indentEdits.length > 0) {
96
111
  const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, indentEdits);
@@ -1,34 +1,30 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.register = void 0;
12
3
  const vscode = require("vscode-languageserver-protocol");
13
4
  const featureWorkers_1 = require("../utils/featureWorkers");
14
5
  function register(context) {
15
- return (uri, position) => __awaiter(this, void 0, void 0, function* () {
16
- return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.apply : !!data.rename), (plugin, document, position) => { var _a, _b; return (_b = (_a = plugin.rename) === null || _a === void 0 ? void 0 : _a.prepare) === null || _b === void 0 ? void 0 : _b.call(_a, document, position); }, (item, map) => {
6
+ return (uri, position) => {
7
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => { var _a, _b; return (_b = (_a = plugin.rename) === null || _a === void 0 ? void 0 : _a.prepare) === null || _b === void 0 ? void 0 : _b.call(_a, document, position); }, (item, map) => {
17
8
  if (!map) {
18
9
  return item;
19
10
  }
20
11
  if (vscode.Range.is(item)) {
21
12
  return map.toSourceRange(item);
22
13
  }
14
+ return item;
23
15
  }, prepares => {
24
16
  for (const prepare of prepares) {
25
17
  if (vscode.Range.is(prepare)) {
26
18
  return prepare; // if has any valid range, ignore other errors
27
19
  }
28
20
  }
29
- return prepares[0];
21
+ const error = prepares[0];
22
+ const newError = new vscode.ResponseError(error.code, error.message);
23
+ newError.name = error.name;
24
+ newError.stack = error.stack;
25
+ return newError;
30
26
  });
31
- });
27
+ };
32
28
  }
33
29
  exports.register = register;
34
30
  //# sourceMappingURL=renamePrepare.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "1.2.0-alpha.13",
3
+ "version": "1.2.0-alpha.14",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -13,15 +13,15 @@
13
13
  "directory": "packages/language-service"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/language-core": "1.2.0-alpha.13",
17
- "@volar/shared": "1.2.0-alpha.13",
18
- "@volar/source-map": "1.2.0-alpha.13",
19
- "@volar/typescript-faster": "1.2.0-alpha.13",
16
+ "@volar/language-core": "1.2.0-alpha.14",
17
+ "@volar/shared": "1.2.0-alpha.14",
18
+ "@volar/source-map": "1.2.0-alpha.14",
19
+ "@volar/typescript-faster": "1.2.0-alpha.14",
20
20
  "vscode-html-languageservice": "^5.0.4",
21
21
  "vscode-json-languageservice": "^5.2.0",
22
22
  "vscode-languageserver-protocol": "^3.17.3",
23
23
  "vscode-languageserver-textdocument": "^1.0.8",
24
24
  "vscode-uri": "^3.0.7"
25
25
  },
26
- "gitHead": "2b935afad2e4e4e307ae525387f66516e496ba24"
26
+ "gitHead": "8257fccecf0ace51d89fff6d6f47a3f95b4ddd10"
27
27
  }