diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index 2ade8007..310236b6 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -302,7 +302,7 @@ class CursorBlinkStateManager { // the regular interval is setup in order to support restarting the blink // animation in a lightweight way (without thrashing clearInterval and // setInterval). - this._blinkStartTimeout = setTimeout(() => { + this._blinkStartTimeout = window.setTimeout(() => { // Check if another animation restart was requested while this was being // started if (this._animationTimeRestarted) { @@ -322,7 +322,7 @@ class CursorBlinkStateManager { }); // Setup the blink interval - this._blinkInterval = setInterval(() => { + this._blinkInterval = window.setInterval(() => { // Adjust the animation time if it was restarted if (this._animationTimeRestarted) { // calc time diff @@ -360,6 +360,9 @@ class CursorBlinkStateManager { } public resume(terminal: Terminal): void { + // Clear out any existing timers just in case + this.pause(); + this._animationTimeRestarted = undefined; this._restartInterval(); this.restartBlinkAnimation(terminal); diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index 8b25667b..607180ae 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -306,7 +306,7 @@ class CursorBlinkStateManager { // the regular interval is setup in order to support restarting the blink // animation in a lightweight way (without thrashing clearInterval and // setInterval). - this._blinkStartTimeout = setTimeout(() => { + this._blinkStartTimeout = window.setTimeout(() => { // Check if another animation restart was requested while this was being // started if (this._animationTimeRestarted) { @@ -326,7 +326,7 @@ class CursorBlinkStateManager { }); // Setup the blink interval - this._blinkInterval = setInterval(() => { + this._blinkInterval = window.setInterval(() => { // Adjust the animation time if it was restarted if (this._animationTimeRestarted) { // calc time diff @@ -364,6 +364,9 @@ class CursorBlinkStateManager { } public resume(): void { + // Clear out any existing timers just in case + this.pause(); + this._animationTimeRestarted = undefined; this._restartInterval(); this.restartBlinkAnimation();