Skip to content

Commit

Permalink
fix: Table component crashing when no headers are present
Browse files Browse the repository at this point in the history
Fixes #38
  • Loading branch information
Im-Beast committed Jan 21, 2024
1 parent e039596 commit 3ef9c71
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}),
});

Expand All @@ -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;
}),
});

Expand Down Expand Up @@ -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;
}),
});

Expand Down

0 comments on commit 3ef9c71

Please sign in to comment.