mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-15 04:05:46 -07:00
Make "before" context work.
No line numbers. And match inverting is broken. This is awful.
This commit is contained in:
@@ -15,15 +15,21 @@ macro_rules! w {
|
||||
|
||||
pub struct Printer<W> {
|
||||
wtr: W,
|
||||
has_printed: bool,
|
||||
}
|
||||
|
||||
impl<W: io::Write> Printer<W> {
|
||||
pub fn new(wtr: W) -> Printer<W> {
|
||||
Printer {
|
||||
wtr: wtr,
|
||||
has_printed: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_printed(&self) -> bool {
|
||||
self.has_printed
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> W {
|
||||
self.wtr
|
||||
}
|
||||
@@ -40,6 +46,10 @@ impl<W: io::Write> Printer<W> {
|
||||
wln!(&mut self.wtr, "{}", count);
|
||||
}
|
||||
|
||||
pub fn context_separator(&mut self) {
|
||||
wln!(&mut self.wtr, "--");
|
||||
}
|
||||
|
||||
pub fn matched<P: AsRef<Path>>(
|
||||
&mut self,
|
||||
path: P,
|
||||
@@ -81,6 +91,7 @@ impl<W: io::Write> Printer<W> {
|
||||
}
|
||||
|
||||
fn write(&mut self, buf: &[u8]) {
|
||||
self.has_printed = true;
|
||||
let _ = self.wtr.write_all(buf);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user