Skip to content

Commit c4fdc9c

Browse files
committed
theme.clear(): also clear the current line.
This was a simple oversight in the code. Make sure to preserve the cursor at the beginning of the current line.
1 parent 29da763 commit c4fdc9c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/theme.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,16 @@ impl<'a> TermThemeRenderer<'a> {
839839
})
840840
}
841841

842+
/// Clear the current theme.
843+
///
844+
/// Position the cursor at the beginning of the current line.
842845
pub fn clear(&mut self) -> io::Result<()> {
846+
// clear the current line first, so the cursor ends at the beginning of the current line.
847+
self.term.clear_line()?;
843848
self.term
844849
.clear_last_lines(self.height + self.prompt_height)?;
850+
// self.term now contains self.height + self.prompt_height empty lines after
851+
// the current line. That doesn't really matter, as these are empty.
845852
self.height = 0;
846853
Ok(())
847854
}

0 commit comments

Comments
 (0)