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
+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');
}
}
}