From a8f33fd630a59d9971d5019bc9f7b70f54002eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20B=C3=B6l=C3=BCk?= Date: Wed, 28 Jan 2026 02:34:50 +0100 Subject: [PATCH] perf(tui): optimized extractCursorPosition to scan lines in reverse order (#1004) - Optimized extractCursorPosition to scan lines in reverse order for improved performance. --- packages/tui/src/tui.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tui/src/tui.ts b/packages/tui/src/tui.ts index 686bfc7a..9f4fac14 100644 --- a/packages/tui/src/tui.ts +++ b/packages/tui/src/tui.ts @@ -772,7 +772,7 @@ export class TUI extends Container { * @returns Cursor position { row, col } or null if no marker found */ private extractCursorPosition(lines: string[]): { row: number; col: number } | null { - for (let row = 0; row < lines.length; row++) { + for (let row = lines.length - 1; row >= 0; row--) { const line = lines[row]; const markerIndex = line.indexOf(CURSOR_MARKER); if (markerIndex !== -1) {