diff options
author | Andrew Gallant <jamslam@gmail.com> | 2016-09-24 19:18:48 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-09-24 19:18:48 -0400 |
commit | 7b860affbeb015aa0298a95b1e23eb8db7d181cc (patch) | |
tree | 44e4de4feef1d71d679d4022f56e6f9971a0002b /src/printer.rs | |
parent | af4dc785370a031b55d709fb7541260c185e1c54 (diff) |
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.
Diffstat (limited to 'src/printer.rs')
-rw-r--r-- | src/printer.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/printer.rs b/src/printer.rs index 9a0dd1e4..999e078a 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -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(); } |