tui: use explicit found flag for cursor scan
Clean up the break logic by using an explicit flag instead of checking cursor_x/cursor_y values.
This commit is contained in:
parent
0f3edebcb3
commit
2e3943b89f
1 changed files with 5 additions and 2 deletions
|
|
@ -829,6 +829,7 @@ impl App {
|
||||||
let mut char_count = 0usize;
|
let mut char_count = 0usize;
|
||||||
let mut cursor_x = input_area.x;
|
let mut cursor_x = input_area.x;
|
||||||
let mut cursor_y = input_area.y;
|
let mut cursor_y = input_area.y;
|
||||||
|
let mut found = false;
|
||||||
|
|
||||||
// Walk through the rendered buffer, counting characters until we reach the cursor position
|
// Walk through the rendered buffer, counting characters until we reach the cursor position
|
||||||
for y in input_area.y..input_area.y + input_area.height {
|
for y in input_area.y..input_area.y + input_area.height {
|
||||||
|
|
@ -841,6 +842,7 @@ impl App {
|
||||||
// Found the cursor position - this is where the next char would go
|
// Found the cursor position - this is where the next char would go
|
||||||
cursor_x = x;
|
cursor_x = x;
|
||||||
cursor_y = y;
|
cursor_y = y;
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char_count += 1;
|
char_count += 1;
|
||||||
|
|
@ -848,12 +850,13 @@ impl App {
|
||||||
// Empty cell but we've reached the cursor position
|
// Empty cell but we've reached the cursor position
|
||||||
cursor_x = x;
|
cursor_x = x;
|
||||||
cursor_y = y;
|
cursor_y = y;
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cursor_x != input_area.x || cursor_y != input_area.y {
|
if found {
|
||||||
break; // Found it
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue