@volar/language-server
Advanced tools
Comparing version 2.4.5 to 2.4.6
@@ -23,7 +23,3 @@ import type * as ts from 'typescript'; | ||
private resetChanges; | ||
/** | ||
* Calculate the change range from the given content changes. | ||
*/ | ||
private calculateChangeRange; | ||
private clearUnreferencedVersions; | ||
} |
@@ -40,12 +40,17 @@ "use strict"; | ||
if (contentChanges.every(change => 'range' in change)) { | ||
const { minStart, oldLength, lengthDiff } = this.calculateChangeRange(contentChanges); | ||
vscode_languageserver_textdocument_1.TextDocument.update(this.document, contentChanges, version); | ||
let changeRanges = []; | ||
for (const contentChange of contentChanges) { | ||
if (!('range' in contentChange)) { | ||
continue; | ||
} | ||
const start = this.offsetAt(contentChange.range.start); | ||
const length = contentChange.rangeLength ?? this.offsetAt(contentChange.range.end) - start; | ||
changeRanges.push({ | ||
span: { start, length }, | ||
newLength: contentChange.text.length | ||
}); | ||
vscode_languageserver_textdocument_1.TextDocument.update(this.document, [contentChange], version); | ||
} | ||
this.snapshots.push({ | ||
changeRange: { | ||
span: { | ||
start: minStart, | ||
length: oldLength, | ||
}, | ||
newLength: oldLength + lengthDiff, | ||
}, | ||
changeRange: (0, combineChangeRanges_1.combineChangeRanges)(...changeRanges), | ||
version, | ||
@@ -107,25 +112,2 @@ ref: undefined, | ||
} | ||
/** | ||
* Calculate the change range from the given content changes. | ||
*/ | ||
calculateChangeRange(contentChanges) { | ||
let lengthDiff = 0; | ||
const starts = []; | ||
const ends = []; | ||
for (const contentChange of contentChanges) { | ||
if (!('range' in contentChange)) { | ||
continue; | ||
} | ||
const start = this.offsetAt(contentChange.range.start); | ||
const length = contentChange.rangeLength ?? this.offsetAt(contentChange.range.end) - start; | ||
const end = start + length; | ||
starts.push(start); | ||
ends.push(end); | ||
lengthDiff += contentChange.text.length - length; | ||
} | ||
const minStart = Math.min(...starts); | ||
const maxEnd = Math.max(...ends); | ||
const oldLength = maxEnd - minStart; | ||
return { minStart, oldLength, lengthDiff }; | ||
} | ||
clearUnreferencedVersions() { | ||
@@ -132,0 +114,0 @@ let firstReferencedIndex = 0; |
{ | ||
"name": "@volar/language-server", | ||
"version": "2.4.5", | ||
"version": "2.4.6", | ||
"license": "MIT", | ||
@@ -15,5 +15,5 @@ "files": [ | ||
"dependencies": { | ||
"@volar/language-core": "2.4.5", | ||
"@volar/language-service": "2.4.5", | ||
"@volar/typescript": "2.4.5", | ||
"@volar/language-core": "2.4.6", | ||
"@volar/language-service": "2.4.6", | ||
"@volar/typescript": "2.4.6", | ||
"path-browserify": "^1.0.1", | ||
@@ -29,3 +29,3 @@ "request-light": "^0.7.0", | ||
}, | ||
"gitHead": "eb9864da6a36535195b906ae33aca3c0f95286a5" | ||
"gitHead": "f4cec29bc563378069be05cf6a92713914c8608b" | ||
} |
144577
2959
+ Added@volar/language-core@2.4.6(transitive)
+ Added@volar/language-service@2.4.6(transitive)
+ Added@volar/source-map@2.4.6(transitive)
+ Added@volar/typescript@2.4.6(transitive)
- Removed@volar/language-core@2.4.5(transitive)
- Removed@volar/language-service@2.4.5(transitive)
- Removed@volar/source-map@2.4.5(transitive)
- Removed@volar/typescript@2.4.5(transitive)
Updated@volar/language-core@2.4.6
Updated@volar/typescript@2.4.6