mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
hide if invalid x
This commit is contained in:
@@ -173,7 +173,7 @@ export class Terminal implements ITerminalApi {
|
||||
}
|
||||
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
|
||||
this._checkProposedApi();
|
||||
this._verifyPositiveInteger(decorationOptions.x);
|
||||
this._verifyPositiveIntegers(decorationOptions.x ?? 0, decorationOptions.width ?? 0, decorationOptions.height ?? 0);
|
||||
return this._core.registerDecoration(decorationOptions);
|
||||
}
|
||||
public addMarker(cursorYOffset: number): IMarker | undefined {
|
||||
@@ -287,9 +287,11 @@ 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');
|
||||
private _verifyPositiveIntegers(...values: number[]): void {
|
||||
for (const value of values) {
|
||||
if (value && (value === Infinity || isNaN(value) || value % 1 !== 0 || value < 0)) {
|
||||
throw new Error('This API only accepts positive integers');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,9 @@ export class Decoration extends Disposable implements IDecoration {
|
||||
this._element.style.height = `${this.height * renderService.dimensions.scaledCellHeight}px`;
|
||||
this._element.style.top = `${(this.marker.line - bufferService.buffers.active.ydisp) * renderService.dimensions.scaledCellHeight}px`;
|
||||
|
||||
if (this.x && this.x > bufferService.cols) {
|
||||
this._element!.style.display = 'none';
|
||||
}
|
||||
if (this.anchor === 'right') {
|
||||
this._element.style.right = this.x ? `${this.x * renderService.dimensions.scaledCellWidth}px` : '';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user