perf(tui): optimized extractCursorPosition to scan lines in reverse order (#1004)

- Optimized extractCursorPosition to scan lines in reverse order for improved performance.
This commit is contained in:
Can Bölük 2026-01-28 02:34:50 +01:00 committed by GitHub
parent 0ad189f12a
commit a8f33fd630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) {