tui: handle empty cells in cursor scan

When scanning the buffer for cursor position, also check empty cells.
The cursor might be positioned at an empty cell (e.g., end of line
or after all visible characters).
This commit is contained in:
ProofOfConcept 2026-03-19 00:47:46 -04:00
parent 1fa298cbdd
commit 0f3edebcb3

View file

@ -838,12 +838,17 @@ impl App {
// Count visible characters (skip zero-width and empty) // Count visible characters (skip zero-width and empty)
if !symbol.is_empty() { if !symbol.is_empty() {
if char_count == cursor_char_pos { if char_count == cursor_char_pos {
// Found the cursor position // Found the cursor position - this is where the next char would go
cursor_x = x; cursor_x = x;
cursor_y = y; cursor_y = y;
break; break;
} }
char_count += 1; char_count += 1;
} else if char_count == cursor_char_pos {
// Empty cell but we've reached the cursor position
cursor_x = x;
cursor_y = y;
break;
} }
} }
} }