From c621c80afcfd6bfb42e4645a129da051fd5d7d2b Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 1 Feb 2026 09:50:57 +0100 Subject: [PATCH] fix(tui): prevent crash when searching with digits in model selector highlightMatch() was replacing tokens inside ANSI escape codes, corrupting sequences like [38;2;123;127;135m when searching for '2'. Fix: apply highlighting to plain text before theme styling. --- src/tui/components/searchable-select-list.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tui/components/searchable-select-list.ts b/src/tui/components/searchable-select-list.ts index 046cc138c..6c15e1b40 100644 --- a/src/tui/components/searchable-select-list.ts +++ b/src/tui/components/searchable-select-list.ts @@ -228,9 +228,9 @@ export class SearchableSelectList implements Component { const remainingWidth = width - descriptionStart - 2; if (remainingWidth > 10) { const truncatedDesc = truncateToWidth(item.description, remainingWidth, ""); - const descText = isSelected - ? this.highlightMatch(truncatedDesc, query) - : this.highlightMatch(this.theme.description(truncatedDesc), query); + // Highlight plain text first, then apply theme styling to avoid corrupting ANSI codes + const highlightedDesc = this.highlightMatch(truncatedDesc, query); + const descText = isSelected ? highlightedDesc : this.theme.description(highlightedDesc); const line = `${prefix}${valueText}${spacing}${descText}`; return isSelected ? this.theme.selectedText(line) : line; }