From 4a7f8c58a0a6c16c1d1e51ff22d92f485d7c505b Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Thu, 6 Aug 2026 22:54:32 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/chat-app/src/index.tsx | 2 +- examples/rss-reader/src/index.tsx | 2 +- examples/todo-app/src/index.ts | 2 +- examples/widget-gallery/src/index.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/chat-app/src/index.tsx b/examples/chat-app/src/index.tsx index a3a2ddb14..0d405714e 100644 --- a/examples/chat-app/src/index.tsx +++ b/examples/chat-app/src/index.tsx @@ -257,7 +257,7 @@ function parseBlocks(text: string): Block[] { } // ── Handle Paragraphs ──────────────────────── - if (line.trim() === '') { + if (line.trim().length === 0) { blocks.push({ type: 'paragraph', text: '', diff --git a/examples/rss-reader/src/index.tsx b/examples/rss-reader/src/index.tsx index 2b269cb81..5ff542b3f 100644 --- a/examples/rss-reader/src/index.tsx +++ b/examples/rss-reader/src/index.tsx @@ -27,7 +27,7 @@ function decodeEntities(value: string): string { return value.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, entity: string) => { if (entity.startsWith('#x')) { - const codePoint = Number.parseInt(entity.slice(2), 16); + const codePoint = Number.parseInt(entity.slice(2, 10), 16); return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match; } 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;