From 8c0eff7dbe258909d9b1b990a228fafb6ccad96e Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Thu, 6 Aug 2026 16:07:51 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/calculator/src/index.tsx | 2 +- packages/dev-server/src/devtools.ts | 2 +- packages/ui/src/MultiSelect.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/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); diff --git a/packages/ui/src/MultiSelect.ts b/packages/ui/src/MultiSelect.ts index b4116418f..327e1eee2 100644 --- a/packages/ui/src/MultiSelect.ts +++ b/packages/ui/src/MultiSelect.ts @@ -30,7 +30,7 @@ export class MultiSelect extends Widget { } get selectedOptions(): MultiSelectOption[] { - return [...this._checked].sort().map(i => this._options[i]); + return [...this._checked].sort((a, b) => a - b).map(i => this._options[i]); } selectNext(): void { if (this._options.length === 0) return; let n = this._cursorIndex + 1; while (n < this._options.length && this._options[n].disabled) n++; if (n < this._options.length) { this._cursorIndex = n; this.markDirty(); } } selectPrev(): void { if (this._options.length === 0) return; let n = this._cursorIndex - 1; while (n >= 0 && this._options[n].disabled) n--; if (n >= 0) { this._cursorIndex = n; this.markDirty(); } }