diff --git a/src/interface.rs b/src/interface.rs index f93818b1..dfdf3463 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -204,13 +204,7 @@ impl<'a> Interface<'a> { fn results(&mut self, screen: &mut W) { let result_top_index = self.result_top_index(); - queue!( - screen, - cursor::Hide, - cursor::MoveTo(1, result_top_index), - Clear(ClearType::All) - ) - .unwrap(); + queue!(screen, cursor::Hide, cursor::MoveTo(1, result_top_index)).unwrap(); let (width, _height): (u16, u16) = terminal::size().unwrap(); @@ -218,7 +212,8 @@ impl<'a> Interface<'a> { self.selection = self.matches.len() - 1; } - for (index, command) in self.matches.iter().enumerate() { + let mut index: usize = 0; + for command in self.matches.iter() { let mut fg = if self.settings.lightmode { Color::Black } else { @@ -249,6 +244,7 @@ impl<'a> Interface<'a> { queue!( screen, cursor::MoveTo(1, (command_line_index + result_top_index as i16) as u16), + Clear(ClearType::CurrentLine), SetBackgroundColor(bg), SetForegroundColor(fg), Print(Interface::truncate_for_display( @@ -320,6 +316,18 @@ impl<'a> Interface<'a> { ) .unwrap(); } + index += 1; + } + // Since we only clear by line instead of clearing the screen each update, + // we need to clear all the lines that may have previously had a command + for i in index..(self.settings.results as usize) { + let command_line_index = self.command_line_index(i as i16); + queue!( + screen, + cursor::MoveTo(1, (command_line_index + result_top_index as i16) as u16), + Clear(ClearType::CurrentLine) + ) + .unwrap(); } }