From 5c5ca4e213c4bfe8b7a1cfa5fb65676af5b37a92 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 19 Mar 2021 06:24:42 -0700 Subject: [PATCH] Change warning to one per session not terminal --- src/common/CoreTerminal.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index a8961451..0236d39f 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -40,6 +40,9 @@ import { IBufferSet } from 'common/buffer/Types'; import { InputHandler } from 'common/InputHandler'; import { WriteBuffer } from 'common/input/WriteBuffer'; +// Only trigger this warning a single time per session +let hasWriteSyncWarnHappened: boolean = false; + export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected readonly _instantiationService: IInstantiationService; protected readonly _bufferService: IBufferService; @@ -135,13 +138,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { * @deprecated Unreliable, will be removed soon. */ public writeSync(data: string | Uint8Array): void { - if (this._logService.logLevel <= LogLevelEnum.WARN && !this._hasBeenWarnedOnce) { + if (this._logService.logLevel <= LogLevelEnum.WARN && !hasWriteSyncWarnHappened) { this._logService.warn('writeSync is unreliable and will be removed soon.'); - this._hasBeenWarnedOnce = true; + hasWriteSyncWarnHappened = true; } this._writeBuffer.writeSync(data); } - private _hasBeenWarnedOnce = false; public resize(x: number, y: number): void { if (isNaN(x) || isNaN(y)) {