19
20
constructor(public readonly lines: string[], private readonly range: Range, public readonly considerWhitespaceChanges: boolean) {
22
>
for (let lineNumber = this.range.startLineNumber; lineNumber <= this.range.endLineNumber; lineNumber++) {
23
>
let line = lines[lineNumber - 1];
24
>
let lineStartOffset = 0;
25
>
if (lineNumber === this.range.startLineNumber && this.range.startColumn > 1) {
26
lineStartOffset = this.range.startColumn - 1;
27
line = line.substring(lineStartOffset);
28
}
30
>
31
>
let trimmedWsLength = 0;
32
>
if (!considerWhitespaceChanges) {
33
const trimmedStartLine = line.trimStart();
34
trimmedWsLength = line.length - trimmedStartLine.length;
35
line = trimmedStartLine.trimEnd();
36
}
38
>
39
>
const lineLength = lineNumber === this.range.endLineNumber ? Math.min(this.range.endColumn - 1 - lineStartOffset - trimmedWsLength, line.length) : line.length;
40
>
for (let i = 0; i < lineLength; i++) {
41
>
this.elements.push(line.charCodeAt(i));
42
>
}
43
>
44
>
if (lineNumber < this.range.endLineNumber) {
45
this.elements.push('\n'.charCodeAt(0));
46
this.firstElementOffsetByLineIdx.push(this.elements.length);
47
}
49
>
}
50
51
toString() {