From 89a0cee5a49006bc29096e69e49efeb530a8423f Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 9 Mar 2022 11:17:26 -0600 Subject: [PATCH] when alt buffer is active, hide decorations --- src/browser/services/DecorationService.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/browser/services/DecorationService.ts b/src/browser/services/DecorationService.ts index ee1bc2e7..0a54adc6 100644 --- a/src/browser/services/DecorationService.ts +++ b/src/browser/services/DecorationService.ts @@ -29,7 +29,7 @@ export class DecorationService extends Disposable implements IDecorationService private readonly _bufferDecorations: BufferDecoration[] = []; private _scrollbarDecorations: ScrollbarDecoration[] = []; - constructor(@IInstantiationService private readonly _instantiationService: IInstantiationService) { super(); } + constructor(@IInstantiationService private readonly _instantiationService: IInstantiationService, @IBufferService private readonly _bufferService: IBufferService) { super(); } public attachToDom(renderService: IRenderService, screenElement: HTMLElement, viewportElement: HTMLElement, scrollbarDecorationNode: HTMLCanvasElement): void { this._renderService = renderService; @@ -40,6 +40,9 @@ export class DecorationService extends Disposable implements IDecorationService this.register(this._renderService.onRenderedBufferChange(() => this._refresh())); this.register(this._renderService.onDimensionsChange(() => this._refresh(true))); this.register(addDisposableDomListener(window, 'resize', () => this._refreshScollbarDecorations())); + this.register(this._bufferService.buffers.onBufferActivate(() => { + this._scrollbarDecorationNode!.style.display = this._bufferService.buffer === this._bufferService.buffers.alt ? 'none' : 'block'; + })); } public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { @@ -87,7 +90,7 @@ export class DecorationService extends Disposable implements IDecorationService this._bufferDecorationContainer.classList.add('xterm-decoration-container'); this._screenElement.appendChild(this._bufferDecorationContainer); } - const decoration = new BufferDecoration(this._instantiationService.createInstance(BufferService), decorationOptions, this._bufferDecorationContainer); + const decoration = new BufferDecoration(this._bufferService, decorationOptions, this._bufferDecorationContainer); this._bufferDecorations.push(decoration); decoration.onDispose(() => this._bufferDecorations.splice(this._bufferDecorations.indexOf(decoration), 1)); this._queueRefresh(); @@ -207,6 +210,8 @@ export class BufferDecoration extends Disposable implements IDecoration { private _onRender = new EventEmitter(); public get onRender(): IEvent { return this._onRender.event; } + private _altBufferIsActive: boolean = false; + public x: number; public anchor: 'left' | 'right'; public width: number; @@ -224,6 +229,9 @@ export class BufferDecoration extends Disposable implements IDecoration { this.anchor = options.anchor || 'left'; this.width = options.width || 1; this.height = options.height || 1; + this.register(this._bufferService.buffers.onBufferActivate(() => { + this._altBufferIsActive = this._bufferService.buffer === this._bufferService.buffers.alt; + })); } public render(renderService: IRenderService, shouldRecreate?: boolean): void { @@ -271,7 +279,7 @@ export class BufferDecoration extends Disposable implements IDecoration { this._element.style.display = 'none'; } else { this._element.style.top = `${line * renderService.dimensions.actualCellHeight}px`; - this._element.style.display = this._bufferService.buffer === this._bufferService.buffers.alt ? 'none' : 'block'; + this._element.style.display = this._altBufferIsActive ? 'none' : 'block'; } }