From abd69f2debc4e292e555708222a6d2f161b6c32a Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 23 Oct 2021 21:41:26 +0900 Subject: [PATCH] Add `bat::PrettyPrinter::clear_highlights` (fixes #1919) --- src/pretty_printer.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index 28644513..674f2929 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -229,6 +229,14 @@ 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) -> &mut Self { self.config.theme = theme.as_ref().to_owned();