@volar/language-server 2.4.5 → 2.4.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.
@@ -20,9 +20,5 @@ export declare class SnapshotDocument implements TextDocument {
20
20
  update(contentChanges: vscode.TextDocumentContentChangeEvent[], version: number): void;
21
21
  getSnapshot(): ts.IScriptSnapshot;
22
22
  private resetChanges;
23
- /**
24
- * Calculate the change range from the given content changes.
25
- */
26
- private calculateChangeRange;
27
23
  private clearUnreferencedVersions;
28
24
  }
@@ -37,16 +37,21 @@ class SnapshotDocument {
37
37
  */
38
38
  update(contentChanges, version) {
39
39
  if (contentChanges.every(change => 'range' in change)) {
40
- const { minStart, oldLength, lengthDiff } = this.calculateChangeRange(contentChanges);
41
- vscode_languageserver_textdocument_1.TextDocument.update(this.document, contentChanges, version);
40
+ let changeRanges = [];
41
+ for (const contentChange of contentChanges) {
42
+ if (!('range' in contentChange)) {
43
+ continue;
44
+ }
45
+ const start = this.offsetAt(contentChange.range.start);
46
+ const length = contentChange.rangeLength ?? this.offsetAt(contentChange.range.end) - start;
47
+ changeRanges.push({
48
+ span: { start, length },
49
+ newLength: contentChange.text.length
50
+ });
51
+ vscode_languageserver_textdocument_1.TextDocument.update(this.document, [contentChange], version);
52
+ }
42
53
  this.snapshots.push({
43
- changeRange: {
44
- span: {
45
- start: minStart,
46
- length: oldLength,
47
- },
48
- newLength: oldLength + lengthDiff,
49
- },
54
+ changeRange: (0, combineChangeRanges_1.combineChangeRanges)(...changeRanges),
50
55
  version,
51
56
  ref: undefined,
52
57
  });
@@ -103,29 +108,6 @@ class SnapshotDocument {
103
108
  }
104
109
  ];
105
110
  }
106
- /**
107
- * Calculate the change range from the given content changes.
108
- */
109
- calculateChangeRange(contentChanges) {
110
- let lengthDiff = 0;
111
- const starts = [];
112
- const ends = [];
113
- for (const contentChange of contentChanges) {
114
- if (!('range' in contentChange)) {
115
- continue;
116
- }
117
- const start = this.offsetAt(contentChange.range.start);
118
- const length = contentChange.rangeLength ?? this.offsetAt(contentChange.range.end) - start;
119
- const end = start + length;
120
- starts.push(start);
121
- ends.push(end);
122
- lengthDiff += contentChange.text.length - length;
123
- }
124
- const minStart = Math.min(...starts);
125
- const maxEnd = Math.max(...ends);
126
- const oldLength = maxEnd - minStart;
127
- return { minStart, oldLength, lengthDiff };
128
- }
129
111
  clearUnreferencedVersions() {
130
112
  let firstReferencedIndex = 0;
131
113
  while (firstReferencedIndex < this.snapshots.length - 1 && !this.snapshots[firstReferencedIndex].ref?.deref()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "2.4.5",
3
+ "version": "2.4.6",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,9 +12,9 @@
12
12
  "directory": "packages/language-server"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "2.4.5",
16
- "@volar/language-service": "2.4.5",
17
- "@volar/typescript": "2.4.5",
15
+ "@volar/language-core": "2.4.6",
16
+ "@volar/language-service": "2.4.6",
17
+ "@volar/typescript": "2.4.6",
18
18
  "path-browserify": "^1.0.1",
19
19
  "request-light": "^0.7.0",
20
20
  "vscode-languageserver": "^9.0.1",
@@ -25,5 +25,5 @@
25
25
  "devDependencies": {
26
26
  "@types/path-browserify": "latest"
27
27
  },
28
- "gitHead": "eb9864da6a36535195b906ae33aca3c0f95286a5"
28
+ "gitHead": "f4cec29bc563378069be05cf6a92713914c8608b"
29
29
  }