From e899eb794f723f6d6960140305a5e68ec44bf053 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Thu, 6 Aug 2026 23:02:29 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/calculator/src/index.tsx | 2 +- examples/pomodoro-timer/src/index.tsx | 2 +- packages/dev-server/src/devtools.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/calculator/src/index.tsx b/examples/calculator/src/index.tsx index 852911990..328248060 100644 --- a/examples/calculator/src/index.tsx +++ b/examples/calculator/src/index.tsx @@ -85,7 +85,7 @@ function safeEval(expr: string): string { if (tokens.length === 0) return '0'; // Handle initial negative number - if (tokens[0] === '-' && tokens.length > 1 && !isNaN(Number(tokens[1]))) { + if (tokens[0] === '-' && tokens.length > 1 && !Number.isNaN(Number(tokens[1]))) { tokens.splice(0, 2, '-' + tokens[1]); } diff --git a/examples/pomodoro-timer/src/index.tsx b/examples/pomodoro-timer/src/index.tsx index cad749f32..6444f948d 100644 --- a/examples/pomodoro-timer/src/index.tsx +++ b/examples/pomodoro-timer/src/index.tsx @@ -182,7 +182,7 @@ class GradientProgressBar extends Widget { const attrs = styleToCellAttrs(this._style); - const label = this._showLabel ? ` ${Math.round(this._value * 100)}%` : ''; + const label = this._showLabel ? ` ${Math.round(this._value * 100 + Number.EPSILON)}%` : ''; const barWidth = Math.max(0, width - label.length); const filled = this._value <= 0 ? 0 : Math.round(barWidth * this._value); const empty = barWidth - filled; diff --git a/packages/dev-server/src/devtools.ts b/packages/dev-server/src/devtools.ts index 17222d074..c820a8b76 100644 --- a/packages/dev-server/src/devtools.ts +++ b/packages/dev-server/src/devtools.ts @@ -98,7 +98,7 @@ export class DevTools { captureFrame(): string { if (this._frameRows.length === 0) return ''; let endIndex = this._frameRows.length; - while (endIndex > 0 && this._frameRows[endIndex - 1].trim() === '') { + while (endIndex > 0 && this._frameRows[endIndex - 1].trim().length === 0) { endIndex--; } const trimmedRows = this._frameRows.slice(0, endIndex);