Skip to content

Commit 60796c9

Browse files
authored
Merge pull request microsoft#232998 from microsoft/tyriar/232994
Accumulate viewport data and render all when ready
2 parents 4ddd518 + a0801bc commit 60796c9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/vs/editor/browser/viewParts/viewLinesGpu/viewLinesGpu.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
4040

4141
private readonly canvas: HTMLCanvasElement;
4242

43+
private _initViewportData?: ViewportData[];
4344
private _lastViewportData?: ViewportData;
4445
private _lastViewLineOptions?: ViewLineOptions;
4546

@@ -285,6 +286,16 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
285286
// endregion Bind group
286287

287288
this._initialized = true;
289+
290+
// Render the initial viewport immediately after initialization
291+
if (this._initViewportData) {
292+
// HACK: Rendering multiple times in the same frame like this isn't ideal, but there
293+
// isn't an easy way to merge viewport data
294+
for (const viewportData of this._initViewportData) {
295+
this.renderText(viewportData);
296+
}
297+
this._initViewportData = undefined;
298+
}
288299
}
289300

290301
private _updateAtlasStorageBufferAndTexture() {
@@ -361,6 +372,9 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
361372
public renderText(viewportData: ViewportData): void {
362373
if (this._initialized) {
363374
return this._renderText(viewportData);
375+
} else {
376+
this._initViewportData = this._initViewportData ?? [];
377+
this._initViewportData.push(viewportData);
364378
}
365379
}
366380

0 commit comments

Comments
 (0)