diff --git a/src/screen.rs b/src/screen.rs index 62ab5a5b4..4bc0684b0 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -317,11 +317,14 @@ pub fn write( // 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 @@ pub fn write( 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