Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/browser/RenderDebouncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class RenderDebouncer implements IRenderDebouncer {
}
}

public requestAnimationFrame(): boolean {
return this._animationFrame === undefined;
}

public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void {
this._rowCount = rowCount;
// Get the min/max row start/end for the arg values
Expand Down
3 changes: 3 additions & 0 deletions src/browser/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ export class MockRenderService implements IRenderService {
public refreshRows(start: number, end: number): void {
throw new Error('Method not implemented.');
}
public getAnimationFrame(): boolean {
throw new Error('Method not implemented.');
}
public clearTextureAtlas(): void {
throw new Error('Method not implemented.');
}
Expand Down
4 changes: 4 additions & 0 deletions src/browser/TimeBasedDebouncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
private readonly _debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS
) {
}
public requestAnimationFrame(): boolean {
const refreshRequestTime: number = Date.now();
return refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS;
}

public dispose(): void {
if (this._refreshTimeoutID) {
Expand Down
1 change: 1 addition & 0 deletions src/browser/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,5 @@ export interface ICharacterJoiner {

export interface IRenderDebouncer extends IDisposable {
refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void;
requestAnimationFrame(): boolean;
}
8 changes: 2 additions & 6 deletions src/browser/decorations/BufferDecorationRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class BufferDecorationRenderer extends Disposable {
private readonly _container: HTMLElement;
private readonly _decorationElements: Map<IInternalDecoration, HTMLElement> = new Map();

private _animationFrame: number | undefined;
private _altBufferIsActive: boolean = false;

constructor(
Expand Down Expand Up @@ -44,13 +43,10 @@ export class BufferDecorationRenderer extends Disposable {
}

private _queueRefresh(): void {
if (this._animationFrame !== undefined) {
if (!this._renderService.getAnimationFrame()) {
return;
}
this._animationFrame = window.requestAnimationFrame(() => {
this.refreshDecorations();
this._animationFrame = undefined;
});
this.refreshDecorations();
}

public refreshDecorations(): void {
Expand Down
4 changes: 4 additions & 0 deletions src/browser/services/RenderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export class RenderService extends Disposable implements IRenderService {
}
}

public getAnimationFrame(): boolean {
return this._renderDebouncer.requestAnimationFrame();
}

private _onIntersectionChange(entry: IntersectionObserverEntry): void {
this._isPaused = entry.isIntersecting === undefined ? (entry.intersectionRatio === 0) : !entry.isIntersecting;

Expand Down
1 change: 1 addition & 0 deletions src/browser/services/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface IRenderService extends IDisposable {
onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
onCursorMove(): void;
clear(): void;
getAnimationFrame(): boolean;
}

export const ISelectionService = createDecorator<ISelectionService>('SelectionService');
Expand Down