mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-03-17 20:28:03 +02:00
Change the default output of --files to elide './'.
This is kind of a ticky-tack change. I do think ./ as a prefix is reasonable default, *but* we strip ./ when showing search results, so it does make sense to be consistent. Fixes #21.
This commit is contained in:
parent
af4dc78537
commit
7b860affbe
@ -4,6 +4,7 @@ use regex::bytes::Regex;
|
||||
use term::{Attr, Terminal};
|
||||
use term::color;
|
||||
|
||||
use pathutil::strip_prefix;
|
||||
use types::FileTypeDef;
|
||||
|
||||
/// Printer encapsulates all output logic for searching.
|
||||
@ -138,7 +139,8 @@ impl<W: Terminal + Send> Printer<W> {
|
||||
|
||||
/// Prints the given path.
|
||||
pub fn path<P: AsRef<Path>>(&mut self, path: P) {
|
||||
self.write(path.as_ref().to_string_lossy().as_bytes());
|
||||
let path = strip_prefix("./", path.as_ref()).unwrap_or(path.as_ref());
|
||||
self.write(path.to_string_lossy().as_bytes());
|
||||
self.write_eol();
|
||||
}
|
||||
|
||||
|
@ -703,11 +703,9 @@ fn files() {
|
||||
cmd.arg("--files");
|
||||
let lines: String = wd.stdout(&mut cmd);
|
||||
if cfg!(windows) {
|
||||
assert!(lines == "./dir\\file\n./file\n"
|
||||
|| lines == "./file\n./dir\\file\n");
|
||||
assert!(lines == "dir\\file\nfile\n" || lines == "file\ndir\\file\n");
|
||||
} else {
|
||||
assert!(lines == "./file\n./dir/file\n"
|
||||
|| lines == "./dir/file\n./file\n");
|
||||
assert!(lines == "file\ndir/file\n" || lines == "dir/file\nfile\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user