Repository: microsoft/TypeScript
File: src/harness/fourslashImpl.ts (TypeScript)

Code before:
        for (const markerName in map) {
            this.goToMarker(markerName);
            const actual = this.languageService.getJsxClosingTagAtPosition(this.activeFile.fileName, this.currentCaretPosition);
            assert.deepEqual(actual, map[markerName], markerName);
        }
    }

    public verifyLinkedEditingRange(map: { [markerName: string]: ts.LinkedEditingInfo | undefined }): void {
        for (const markerName in map) {
            this.goToMarker(markerName);
            const actual = this.languageService.getLinkedEditingRangeAtPosition(this.activeFile.fileName, this.currentCaretPosition);
            assert.deepEqual(actual, map[markerName], markerName);
        }
    }

    public baselineLinkedEditing(): void {
        const baselineFile = this.getBaselineFileNameForContainingTestFile(".linkedEditing.txt");
        const files = this.testData.files;

        let baselineContent = "";
        let offset = 0;
        files.forEach(f => {
            const result = getLinkedEditingBaselineWorker(f, offset, this.languageService);
            baselineContent += result.baselineContent + `\n\n\n`;
            offset = result.offset;
        });

        Harness.Baseline.runBaseline(baselineFile, baselineContent);

        function getLinkedEditingBaselineWorker(activeFile: FourSlashFile, offset: number, languageService: ts.LanguageService) {
            const fileName = activeFile.fileName;
            let baselineContent = `=== ${fileName} ===\n`;

            // get linkedEdit at every position in the file, then group positions by their linkedEdit
            const linkedEditsInFile = new Map<string, number[]>();
            for(let pos = 0; pos < activeFile.content.length; pos++) {
                const linkedEditAtPosition = languageService.getLinkedEditingRangeAtPosition(fileName, pos);
                if (!linkedEditAtPosition) continue;

                const linkedEditString = JSON.stringify(linkedEditAtPosition);
                const existingPositions = linkedEditsInFile.get(linkedEditString) ?? [];
                linkedEditsInFile.set(linkedEditString, [...existingPositions, pos]);
            }

            const linkedEditsByRange = [...linkedEditsInFile.entries()].sort((a, b) => a[1][0] - b[1][0]);
            if (linkedEditsByRange.length === 0) {
                return { baselineContent: baselineContent + activeFile.content + `\n\n--No linked edits found--`, offset };
            }

            let inlineLinkedEditBaseline: { start: number, end: number, index: number }[] = [];
            let linkedEditInfoBaseline = "";

Review comment (suggestion):
nit - just use a for-of loop

```suggestion
        for (const f of files) {
            const result = getLinkedEditingBaselineWorker(f, offset, this.languageService);
            baselineContent += result.baselineContent + `\n\n\n`;
            offset = result.offset;
        }
```

Code after:
                    const text = this.getFileContent(fileName);
                    baselineText += "\n" + codeFence(text, lang) + "\n\n";
                }
            }
        }

        Harness.Baseline.runBaseline(baselineFile, baselineText);
    }

    public verifyJsxClosingTag(map: { [markerName: string]: ts.JsxClosingTagInfo | undefined }): void {
        for (const markerName in map) {
            this.goToMarker(markerName);
            const actual = this.languageService.getJsxClosingTagAtPosition(this.activeFile.fileName, this.currentCaretPosition);
            assert.deepEqual(actual, map[markerName], markerName);
        }
    }

    public verifyLinkedEditingRange(map: { [markerName: string]: ts.LinkedEditingInfo | undefined }): void {
        for (const markerName in map) {
            this.goToMarker(markerName);
            const actual = this.languageService.getLinkedEditingRangeAtPosition(this.activeFile.fileName, this.currentCaretPosition);
            assert.deepEqual(actual, map[markerName], markerName);
        }
    }

    public baselineLinkedEditing(): void {
        const baselineFile = this.getBaselineFileNameForContainingTestFile(".linkedEditing.txt");
        const files = this.testData.files;

        let baselineContent = "";
        let offset = 0;
        for (const f of files) {
            const result = getLinkedEditingBaselineWorker(f, offset, this.languageService);
            baselineContent += result.baselineContent + `\n\n\n`;
            offset = result.offset;
        }

        Harness.Baseline.runBaseline(baselineFile, baselineContent);

        function getLinkedEditingBaselineWorker(activeFile: FourSlashFile, offset: number, languageService: ts.LanguageService) {
            const fileName = activeFile.fileName;
            let baselineContent = `=== ${fileName} ===\n`;

            // get linkedEdit at every position in the file, then group positions by their linkedEdit
            const linkedEditsInFile = new Map<string, number[]>();
            for(let pos = 0; pos < activeFile.content.length; pos++) {
                const linkedEditAtPosition = languageService.getLinkedEditingRangeAtPosition(fileName, pos);
                if (!linkedEditAtPosition) continue;

                const linkedEditString = JSON.stringify(linkedEditAtPosition);
                const existingPositions = linkedEditsInFile.get(linkedEditString) ?? [];