From 4af4d6c6a137bee99ecdf40c9433fff502d09223 Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Wed, 1 Nov 2023 11:03:47 +0100 Subject: [PATCH] fix(dev): fix crash on very narrow terminals (#5327) Before this fix, commands in a dev command session would fail with an error if the terminal width was less than the length of the command (including opts and args). --- core/src/logger/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/logger/util.ts b/core/src/logger/util.ts index 306229ccf6..b6c52bc224 100644 --- a/core/src/logger/util.ts +++ b/core/src/logger/util.ts @@ -74,7 +74,7 @@ interface DividerOpts { padding?: number } -const getSideDividerWidth = (width: number, titleWidth: number) => (width - titleWidth) / 2 +const getSideDividerWidth = (width: number, titleWidth: number) => Math.max((width - titleWidth) / 2, 1) const getNumberOfCharsPerWidth = (char: string, width: number) => width / stringWidth(char) // Adapted from https://github.com/JureSotosek/ink-divider