mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-26 16:28:50 +01:00
Clear highlighted_lines
when calling PrettyPrinter::print
This commit is contained in:
parent
abd69f2deb
commit
3d7817d662
@ -229,14 +229,6 @@ impl<'a> PrettyPrinter<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Clear highlighted lines added by [`PrettyPrinter::highlight`] and
|
||||
/// [`PrettyPrinter::highlight_range`]. This is useful when reusing a
|
||||
/// `PrettyPrinter` instance for multiple different ranges.
|
||||
pub fn clear_highlights(&mut self) -> &mut Self {
|
||||
self.highlighted_lines.clear();
|
||||
self
|
||||
}
|
||||
|
||||
/// Specify the highlighting theme
|
||||
pub fn theme(&mut self, theme: impl AsRef<str>) -> &mut Self {
|
||||
self.config.theme = theme.as_ref().to_owned();
|
||||
@ -271,8 +263,8 @@ impl<'a> PrettyPrinter<'a> {
|
||||
/// If you want to call 'print' multiple times, you have to call the appropriate
|
||||
/// input_* methods again.
|
||||
pub fn print(&mut self) -> Result<bool> {
|
||||
self.config.highlighted_lines =
|
||||
HighlightedLineRanges(LineRanges::from(self.highlighted_lines.clone()));
|
||||
let highlight_lines = std::mem::take(&mut self.highlighted_lines);
|
||||
self.config.highlighted_lines = HighlightedLineRanges(LineRanges::from(highlight_lines));
|
||||
self.config.term_width = self
|
||||
.term_width
|
||||
.unwrap_or_else(|| Term::stdout().size().1 as usize);
|
||||
|
Loading…
Reference in New Issue
Block a user