Skip to content

Commit 8a8956a

Browse files
committed
refactors
1 parent e00ab81 commit 8a8956a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/harness/fourslashImpl.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,11 +3582,11 @@ export class TestState {
35823582

35833583
let baselineContent = "";
35843584
let offset = 0;
3585-
files.forEach(f => {
3585+
for (const f of files) {
35863586
const result = getLinkedEditingBaselineWorker(f, offset, this.languageService);
35873587
baselineContent += result.baselineContent + `\n\n\n`;
35883588
offset = result.offset;
3589-
});
3589+
}
35903590

35913591
Harness.Baseline.runBaseline(baselineFile, baselineContent);
35923592

@@ -3610,34 +3610,35 @@ export class TestState {
36103610
return { baselineContent: baselineContent + activeFile.content + `\n\n--No linked edits found--`, offset };
36113611
}
36123612

3613-
let inlineLinkedEditBaseline: { start: number, end: number, index: number }[] = [];
3613+
let inlineLinkedEditBaselines: { start: number, end: number, index: number }[] = [];
36143614
let linkedEditInfoBaseline = "";
3615-
linkedEditsByRange.forEach(([linkedEdit, positions]) => {
3615+
for (const edit of linkedEditsByRange) {
3616+
const [linkedEdit, positions] = edit;
36163617
let rangeStart = 0;
36173618
for (let j = 0; j < positions.length - 1; j++) {
36183619
// for each distinct range in the list of positions, add an entry to the list of places that need to be annotated in the baseline
36193620
if (positions[j] + 1 !== positions[j + 1]) {
3620-
inlineLinkedEditBaseline.push({ start: positions[rangeStart], end: positions[j], index: offset });
3621+
inlineLinkedEditBaselines.push({ start: positions[rangeStart], end: positions[j], index: offset });
36213622
rangeStart = j + 1;
36223623
}
36233624
}
3624-
inlineLinkedEditBaseline.push({ start: positions[rangeStart], end: positions[positions.length - 1], index: offset });
3625+
inlineLinkedEditBaselines.push({ start: positions[rangeStart], end: positions[positions.length - 1], index: offset });
36253626

36263627
// add the LinkedEditInfo with its index to the baseline
36273628
linkedEditInfoBaseline += `\n\n=== ${offset} ===\n` + linkedEdit;
36283629
offset++;
3629-
});
3630+
}
36303631

3631-
inlineLinkedEditBaseline = inlineLinkedEditBaseline.sort((a, b) => a.start - b.start);
3632+
inlineLinkedEditBaselines = inlineLinkedEditBaselines.sort((a, b) => a.start - b.start);
36323633
const fileText = activeFile.content;
3633-
baselineContent += fileText.slice(0, inlineLinkedEditBaseline[0].start);
3634-
for (let i = 0 ; i < inlineLinkedEditBaseline.length - 1; i++) {
3635-
const e = inlineLinkedEditBaseline[i];
3636-
baselineContent += `[|/*${e.index}*/` + fileText.slice(e.start, e.end) + `|]` + fileText.slice(e.end, inlineLinkedEditBaseline[i + 1].start);
3634+
baselineContent += fileText.slice(0, inlineLinkedEditBaselines[0].start);
3635+
for (let i = 0; i < inlineLinkedEditBaselines.length; i++) {
3636+
const e = inlineLinkedEditBaselines[i];
3637+
const sliceEnd = inlineLinkedEditBaselines[i + 1]?.start;
3638+
baselineContent += `[|/*${e.index}*/` + fileText.slice(e.start, e.end) + `|]` + fileText.slice(e.end, sliceEnd);
36373639
}
3638-
const n = inlineLinkedEditBaseline[inlineLinkedEditBaseline.length - 1];
3639-
baselineContent += `[|/*${n.index}*/` + fileText.slice(n.start, n.end) + `|]` + fileText.slice(inlineLinkedEditBaseline[inlineLinkedEditBaseline.length - 1].end) + linkedEditInfoBaseline;
36403640

3641+
baselineContent += linkedEditInfoBaseline;
36413642
return { baselineContent, offset };
36423643
}
36433644
}

0 commit comments

Comments
 (0)