From 6b11e8c72e25d94ca1470f1a35a02a0fb1ac7d3d Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Tue, 4 Aug 2026 10:58:43 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/pomodoro-timer/src/index.tsx | 2 +- examples/todo-app/src/index.ts | 2 +- examples/widget-gallery/src/index.ts | 2 +- packages/ui/src/TreeSelect.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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/examples/todo-app/src/index.ts b/examples/todo-app/src/index.ts index d26035d3c..d4cf9b550 100644 --- a/examples/todo-app/src/index.ts +++ b/examples/todo-app/src/index.ts @@ -104,7 +104,7 @@ class CustomMultiProgress extends (MultiProgressClass as any) { const value = Math.max(0, Math.min(1, item.value)); const filled = Math.round(barWidth * value); - const pct = Math.round(value * 100); + const pct = Math.round(value * 100 + Number.EPSILON); const percentStr = ` ${pct}% `; const showPct = barWidth >= percentStr.length; const labelStart = showPct ? Math.floor((barWidth - percentStr.length) / 2) : -1; diff --git a/examples/widget-gallery/src/index.ts b/examples/widget-gallery/src/index.ts index 57b141244..ec688a7fc 100644 --- a/examples/widget-gallery/src/index.ts +++ b/examples/widget-gallery/src/index.ts @@ -129,7 +129,7 @@ class WidgetGalleryApp extends Widget { } // Tab switching: 1-6 - const num = parseInt(event.key); + const num = parseInt(event.key, 10); if (num >= 1 && num <= 6) { this._switchTab(num - 1); return true; diff --git a/packages/ui/src/TreeSelect.ts b/packages/ui/src/TreeSelect.ts index 652ede256..2c3a59a97 100644 --- a/packages/ui/src/TreeSelect.ts +++ b/packages/ui/src/TreeSelect.ts @@ -182,7 +182,7 @@ function _pathsEqual(a: number[], b: number[]): boolean { function _valuesEqual(a: string[], b: string[]): boolean { if (a.length !== b.length) return false; - const sortedA = [...a].sort(); + const sortedA = [...a].sort((a, b) => a - b); const sortedB = [...b].sort(); for (let i = 0; i < sortedA.length; i++) { if (sortedA[i] !== sortedB[i]) return false;