From 3ef9c715da5e681e21f7eb22f2d17ff79e7b58f3 Mon Sep 17 00:00:00 2001 From: Im-Beast Date: Sun, 21 Jan 2024 13:16:10 +0100 Subject: [PATCH] fix: `Table` component crashing when no headers are present Fixes #38 --- src/components/table.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/table.ts b/src/components/table.ts index 430a73a..b7907c3 100644 --- a/src/components/table.ts +++ b/src/components/table.ts @@ -266,7 +266,7 @@ export class Table extends Component { }), value: new Computed(() => { const { topLeft, horizontal, topRight } = this.charMap.value; - return topLeft + horizontal.repeat(this.rectangle.value.width - 2) + topRight; + return topLeft + horizontal.repeat(Math.max(this.rectangle.value.width - 2, 0)) + topRight; }), }); @@ -284,7 +284,7 @@ export class Table extends Component { }), value: new Computed(() => { const { bottomLeft, horizontal, bottomRight } = this.charMap.value; - return bottomLeft + horizontal.repeat(this.rectangle.value.width - 2) + bottomRight; + return bottomLeft + horizontal.repeat(Math.max(this.rectangle.value.width - 2, 0)) + bottomRight; }), }); @@ -335,7 +335,7 @@ export class Table extends Component { }), value: new Computed(() => { const { leftHorizontal, horizontal, rightHorizontal } = this.charMap.value; - return leftHorizontal + horizontal.repeat(this.rectangle.value.width - 2) + rightHorizontal; + return leftHorizontal + horizontal.repeat(Math.max(this.rectangle.value.width - 2, 0)) + rightHorizontal; }), });