1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-06-14 22:15:13 +02:00

printer: move PathPrinter into grep-printer

I originally did not put PathPrinter into grep-printer because I
considered it somewhat extraneous to what a "grep" program does, and
also that its implementation was rather simple. But now with hyperlink
support, its implementation has grown a smidge more complicated. And
more importantly, its existence required exposing a lot more of the
hyperlink guts. Without it, we can keep things like HyperlinkPath and
HyperlinkSpan completely private.

We can now also keep `PrinterPath` completely private as well. And this
is a breaking change.
This commit is contained in:
Andrew Gallant
2023-09-21 17:28:58 -04:00
parent 09905560ff
commit 23e21133ba
9 changed files with 222 additions and 159 deletions

View File

@ -16,7 +16,6 @@ mod app;
mod args;
mod config;
mod logger;
mod path_printer;
mod search;
mod subject;
@ -248,7 +247,7 @@ fn files(args: &Args) -> Result<bool> {
if quit_after_match {
break;
}
if let Err(err) = path_printer.write_path(subject.path()) {
if let Err(err) = path_printer.write(subject.path()) {
// A broken pipe means graceful termination.
if err.kind() == io::ErrorKind::BrokenPipe {
break;
@ -293,7 +292,7 @@ fn files_parallel(args: &Args) -> Result<bool> {
let print_thread = thread::spawn(move || -> io::Result<()> {
for subject in rx.iter() {
path_printer.write_path(subject.path())?;
path_printer.write(subject.path())?;
}
Ok(())
});