Defer paused renderer resize to idle callback
This commit is contained in:
@@ -12,6 +12,7 @@ import { addDisposableDomListener } from 'browser/Lifecycle';
|
|||||||
import { IColorSet, IRenderDebouncerWithCallback } from 'browser/Types';
|
import { IColorSet, IRenderDebouncerWithCallback } from 'browser/Types';
|
||||||
import { IOptionsService, IBufferService, IDecorationService } from 'common/services/Services';
|
import { IOptionsService, IBufferService, IDecorationService } from 'common/services/Services';
|
||||||
import { ICharSizeService, ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
import { ICharSizeService, ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
||||||
|
import { IdleTaskQueue } from 'common/IdleTaskQueue';
|
||||||
|
|
||||||
interface ISelectionState {
|
interface ISelectionState {
|
||||||
start: [number, number] | undefined;
|
start: [number, number] | undefined;
|
||||||
@@ -105,6 +106,7 @@ export class RenderService extends Disposable implements IRenderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this._isPaused && this._needsFullRefresh) {
|
if (!this._isPaused && this._needsFullRefresh) {
|
||||||
|
this._pausedResizeQueue.flush();
|
||||||
this.refreshRows(0, this._rowCount - 1);
|
this.refreshRows(0, this._rowCount - 1);
|
||||||
this._needsFullRefresh = false;
|
this._needsFullRefresh = false;
|
||||||
}
|
}
|
||||||
@@ -203,8 +205,14 @@ export class RenderService extends Disposable implements IRenderService {
|
|||||||
this.refreshRows(0, this._rowCount - 1);
|
this.refreshRows(0, this._rowCount - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _pausedResizeQueue = new IdleTaskQueue();
|
||||||
public onResize(cols: number, rows: number): void {
|
public onResize(cols: number, rows: number): void {
|
||||||
this._renderer.onResize(cols, rows);
|
if (this._isPaused) {
|
||||||
|
this._pausedResizeQueue.clear();
|
||||||
|
this._pausedResizeQueue.enqueue(() => this._renderer.onResize(cols, rows));
|
||||||
|
} else {
|
||||||
|
this._renderer.onResize(cols, rows);
|
||||||
|
}
|
||||||
this._fullRefresh();
|
this._fullRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,28 @@ export class IdleTaskQueue {
|
|||||||
this._start();
|
this._start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flushes the queue, running all remaining tasks synchronously.
|
||||||
|
*/
|
||||||
|
public flush(): void {
|
||||||
|
while (this._i < this._tasks.length) {
|
||||||
|
this._tasks[this._i++]();
|
||||||
|
}
|
||||||
|
this.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears any remaining tasks from the queue, these will not be run.
|
||||||
|
*/
|
||||||
|
public clear(): void {
|
||||||
|
if (this._idleCallback) {
|
||||||
|
cancelIdleCallback(this._idleCallback);
|
||||||
|
this._idleCallback = undefined;
|
||||||
|
}
|
||||||
|
this._i = 0;
|
||||||
|
this._tasks.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
private _start(): void {
|
private _start(): void {
|
||||||
if (!this._idleCallback) {
|
if (!this._idleCallback) {
|
||||||
this._idleCallback = requestIdleCallback(() => this._process());
|
this._idleCallback = requestIdleCallback(() => this._process());
|
||||||
@@ -45,8 +67,6 @@ export class IdleTaskQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Clear the queue
|
this.clear();
|
||||||
this._i = 0;
|
|
||||||
this._tasks.length = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user