From db9bdd46b4b633cc24f469366bc7d4158e3b9724 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 9 Feb 2022 08:56:45 -0600 Subject: [PATCH] fix some things --- css/xterm.css | 2 +- src/browser/Terminal.ts | 7 +------ src/browser/public/Terminal.ts | 10 +++++++--- src/browser/services/DecorationService.ts | 3 --- test/api/Terminal.api.ts | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/css/xterm.css b/css/xterm.css index f8bfcd23..956f6675 100644 --- a/css/xterm.css +++ b/css/xterm.css @@ -174,7 +174,7 @@ text-decoration: line-through; } -.xterm-screen .xterm-decorations .xterm-decoration { +.xterm-screen .xterm-decoration { z-index: 6; position: absolute; } diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index f1c799f2..703c995b 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -159,6 +159,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.linkifier = this._instantiationService.createInstance(Linkifier); this.linkifier2 = this.register(this._instantiationService.createInstance(Linkifier2)); + this.decorationService = this.register(this._instantiationService.createInstance(DecorationService)); // Setup InputHandler listeners this.register(this._inputHandler.onRequestBell(() => this.bell())); @@ -174,8 +175,6 @@ export class Terminal extends CoreTerminal implements ITerminal { // Setup listeners this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows))); - - this.decorationService = this.register(this._instantiationService.createInstance(DecorationService)); } /** @@ -1004,10 +1003,6 @@ export class Terminal extends CoreTerminal implements ITerminal { } public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { - // Disallow decorations on the alt buffer - if (this.buffer !== this.buffers.normal) { - return undefined; - } return this.decorationService!.registerDecoration(decorationOptions); } diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index ff2f88cf..7b2e7ee6 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -173,9 +173,7 @@ export class Terminal implements ITerminalApi { } public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { this._checkProposedApi(); - if (decorationOptions.x) { - this._verifyIntegers(decorationOptions.x); - } + this._verifyPositiveInteger(decorationOptions.x); return this._core.registerDecoration(decorationOptions); } public addMarker(cursorYOffset: number): IMarker | undefined { @@ -288,4 +286,10 @@ export class Terminal implements ITerminalApi { } } } + + private _verifyPositiveInteger(value?: number): void { + if (value && (value === Infinity || isNaN(value) || value % 1 !== 0 || value < 0)) { + throw new Error('This API only accepts positive integers'); + } + } } diff --git a/src/browser/services/DecorationService.ts b/src/browser/services/DecorationService.ts index 2fea87c3..08d570e3 100644 --- a/src/browser/services/DecorationService.ts +++ b/src/browser/services/DecorationService.ts @@ -115,9 +115,6 @@ class Decoration extends Disposable implements IDecoration { this._element.style.width = `${this._decorationOptions.width}px`; this._element.style.height = `${this._decorationOptions.height}px`; this._element.style.top = `${(this.marker.line - this._bufferService.buffers.active.ydisp) * this._renderService.dimensions.scaledCellHeight}px`; - if (this._decorationOptions.x && this._decorationOptions.x < 0) { - throw new Error(`Decoration options x value cannot be negative, but was ${this._decorationOptions.x}.`); - } if (this._decorationOptions.anchor === 'right') { this._element.style.right = this._decorationOptions.x ? `${this._decorationOptions.x * this._renderService.dimensions.scaledCellWidth}px` : ''; diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 22964998..2f428803 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -755,7 +755,7 @@ describe('API Integration Tests', function(): void { window.throwMessage = e.message; } `); - await pollFor(page, 'window.throwMessage', 'Decoration options x value cannot be negative, but was -2.'); + await pollFor(page, 'window.throwMessage', 'This API only accepts positive integers'); assert.equal(await page.evaluate(`document.querySelector('.xterm-screen .xterm-decoration')`), undefined); }); });