Fix code duplication in commandline rendering

Will use this in the next commit.
This commit is contained in:
Johannes Altmanninger 2024-10-25 08:20:20 +02:00
parent 0d5e6f356e
commit 50333d8d00

View File

@ -317,11 +317,14 @@ impl Screen {
// Output the command line.
let mut i = 0;
while i < effective_commandline.len() {
loop {
// Grab the current cursor's x,y position if this character matches the cursor's offset.
if !cursor_is_within_pager && i == cursor_pos {
cursor_arr = self.desired.cursor;
}
if i == effective_commandline.len() {
break;
}
self.desired_append_char(
effective_commandline.as_char_slice()[i],
colors[i],
@ -332,11 +335,6 @@ impl Screen {
i += 1;
}
// Cursor may have been at the end too.
if !cursor_is_within_pager && i == cursor_pos {
cursor_arr = self.desired.cursor;
}
let full_line_count = self.desired.cursor.y + 1;
// Now that we've output everything, set the cursor to the position that we saved in the loop