fix some things

This commit is contained in:
meganrogge
2022-02-09 08:56:45 -06:00
parent fb4b19a393
commit db9bdd46b4
5 changed files with 10 additions and 14 deletions
+1 -1
View File
@@ -174,7 +174,7 @@
text-decoration: line-through;
}
.xterm-screen .xterm-decorations .xterm-decoration {
.xterm-screen .xterm-decoration {
z-index: 6;
position: absolute;
}
+1 -6
View File
@@ -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);
}
+7 -3
View File
@@ -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');
}
}
}
@@ -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` : '';
+1 -1
View File
@@ -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);
});
});