mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user