diff options
author | David Peter <sharkdp@users.noreply.github.com> | 2022-09-06 09:32:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 09:32:29 +0200 |
commit | 0e03dce130aac185190d5176c2ea075aaddd5ed2 (patch) | |
tree | c2b2794a0ddcb277912a87bdccfe3e68a89139a5 | |
parent | b213949aebad416e786e10a37d4d9f077ef829ba (diff) | |
parent | 6a0ab0095aabd32acde1fff4cd54cf6582f6624e (diff) |
Merge pull request #1920 from rhysd/issue-1919
Add `bat::PrettyPrinter::clear_highlights`
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/pretty_printer.rs | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c113df4..1b5c3c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ ## `bat` as a library - Make `bat::PrettyPrinter::syntaxes()` iterate over new `bat::Syntax` struct instead of `&syntect::parsing::SyntaxReference`. See #2222 (@Enselic) +- Clear highlights after printing, see #1919 and #1920 (@rhysd) # v0.21.0 diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index 28644513..0d68ba40 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -263,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); |