Skip to content

Commit

Permalink
Merge pull request #4984 from tisilent/fix-#4983
Browse files Browse the repository at this point in the history
Clear timer when dispose
  • Loading branch information
Tyriar committed Apr 21, 2024
2 parents 0d799ba + fe22671 commit 292042e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/browser/Viewport.ts
Expand Up @@ -51,6 +51,8 @@ export class Viewport extends Disposable implements IViewport {
target: -1
};

private _ensureTimeout: number;

private readonly _onRequestScrollLines = this.register(new EventEmitter<{ amount: number, suppressScrollEvent: boolean }>());
public readonly onRequestScrollLines = this._onRequestScrollLines.event;

Expand Down Expand Up @@ -83,7 +85,7 @@ export class Viewport extends Disposable implements IViewport {
this.register(this._optionsService.onSpecificOptionChange('scrollback', () => this.syncScrollArea()));

// Perform this async to ensure the ICharSizeService is ready.
setTimeout(() => this.syncScrollArea());
this._ensureTimeout = window.setTimeout(() => this.syncScrollArea());
}

private _handleThemeChange(colors: ReadonlyColorSet): void {
Expand Down Expand Up @@ -405,4 +407,8 @@ export class Viewport extends Disposable implements IViewport {
this._viewportElement.scrollTop += deltaY;
return this._bubbleScroll(ev, deltaY);
}

public dispose(): void {
clearTimeout(this._ensureTimeout);
}
}

0 comments on commit 292042e

Please sign in to comment.