ripgrep: max-column-preview --> max-columns-preview

Credit to @okdana for catching this. This naming is a bit more
consistent with the existing --max-columns flag.
This commit is contained in:
Andrew Gallant 2019-04-15 06:51:51 -04:00
parent 45d12abbc5
commit ef1611b5f5
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44
7 changed files with 34 additions and 34 deletions

View File

@ -50,7 +50,7 @@ Feature enhancements:
* [FEATURE #855](https://github.com/BurntSushi/ripgrep/issues/855): * [FEATURE #855](https://github.com/BurntSushi/ripgrep/issues/855):
Add `--binary` flag for disabling binary file filtering. Add `--binary` flag for disabling binary file filtering.
* [FEATURE #1078](https://github.com/BurntSushi/ripgrep/pull/1078): * [FEATURE #1078](https://github.com/BurntSushi/ripgrep/pull/1078):
Add `--max-column-preview` flag for showing a preview of long lines. Add `--max-columns-preview` flag for showing a preview of long lines.
* [FEATURE #1099](https://github.com/BurntSushi/ripgrep/pull/1099): * [FEATURE #1099](https://github.com/BurntSushi/ripgrep/pull/1099):
Add support for Brotli and Zstd to the `-z/--search-zip` flag. Add support for Brotli and Zstd to the `-z/--search-zip` flag.
* [FEATURE #1138](https://github.com/BurntSushi/ripgrep/pull/1138): * [FEATURE #1138](https://github.com/BurntSushi/ripgrep/pull/1138):

View File

@ -540,7 +540,7 @@ formatting peculiarities:
$ cat $HOME/.ripgreprc $ cat $HOME/.ripgreprc
# Don't let ripgrep vomit really long lines to my terminal, and show a preview. # Don't let ripgrep vomit really long lines to my terminal, and show a preview.
--max-columns=150 --max-columns=150
--max-column-preview --max-columns-preview
# Add my 'web' type. # Add my 'web' type.
--type-add --type-add

View File

@ -153,9 +153,9 @@ _rg() {
$no"--no-crlf[don't use CRLF as line terminator]" $no"--no-crlf[don't use CRLF as line terminator]"
'(text)--null-data[use NUL as line terminator]' '(text)--null-data[use NUL as line terminator]'
+ '(max-column-preview)' # max column preview options + '(max-columns-preview)' # max column preview options
'--max-column-preview[show preview for long lines (with -M)]' '--max-columne-preview[show preview for long lines (with -M)]'
$no"--no-max-column-preview[don't show preview for long lines (with -M)]" $no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
+ '(max-depth)' # Directory-depth options + '(max-depth)' # Directory-depth options
'--max-depth=[specify max number of directories to descend]:number of directories' '--max-depth=[specify max number of directories to descend]:number of directories'

View File

@ -34,7 +34,7 @@ struct Config {
per_match: bool, per_match: bool,
replacement: Arc<Option<Vec<u8>>>, replacement: Arc<Option<Vec<u8>>>,
max_columns: Option<u64>, max_columns: Option<u64>,
max_column_preview: bool, max_columns_preview: bool,
max_matches: Option<u64>, max_matches: Option<u64>,
column: bool, column: bool,
byte_offset: bool, byte_offset: bool,
@ -58,7 +58,7 @@ impl Default for Config {
per_match: false, per_match: false,
replacement: Arc::new(None), replacement: Arc::new(None),
max_columns: None, max_columns: None,
max_column_preview: false, max_columns_preview: false,
max_matches: None, max_matches: None,
column: false, column: false,
byte_offset: false, byte_offset: false,
@ -273,8 +273,8 @@ impl StandardBuilder {
/// If no limit is set, then enabling this has no effect. /// If no limit is set, then enabling this has no effect.
/// ///
/// This is disabled by default. /// This is disabled by default.
pub fn max_column_preview(&mut self, yes: bool) -> &mut StandardBuilder { pub fn max_columns_preview(&mut self, yes: bool) -> &mut StandardBuilder {
self.config.max_column_preview = yes; self.config.max_columns_preview = yes;
self self
} }
@ -1273,7 +1273,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
matches: &[Match], matches: &[Match],
match_index: &mut usize, match_index: &mut usize,
) -> io::Result<()> { ) -> io::Result<()> {
if self.config().max_column_preview { if self.config().max_columns_preview {
let original = line; let original = line;
let end = BStr::new(&bytes[line]) let end = BStr::new(&bytes[line])
.grapheme_indices() .grapheme_indices()
@ -2342,7 +2342,7 @@ but Doctor Watson has to have it taken out for him and dusted,
let matcher = RegexMatcher::new("exhibited|dusted").unwrap(); let matcher = RegexMatcher::new("exhibited|dusted").unwrap();
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.max_columns(Some(46)) .max_columns(Some(46))
.max_column_preview(true) .max_columns_preview(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
.line_number(false) .line_number(false)
@ -2393,7 +2393,7 @@ but Doctor Watson has to have it taken out for him and dusted,
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.stats(true) .stats(true)
.max_columns(Some(46)) .max_columns(Some(46))
.max_column_preview(true) .max_columns_preview(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
.line_number(false) .line_number(false)
@ -2419,7 +2419,7 @@ and exhibited clearly, with a label attached.
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.stats(true) .stats(true)
.max_columns(Some(46)) .max_columns(Some(46))
.max_column_preview(true) .max_columns_preview(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
.line_number(false) .line_number(false)
@ -2447,7 +2447,7 @@ and exhibited clearly, with a label attached.
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.stats(true) .stats(true)
.max_columns(Some(46)) .max_columns(Some(46))
.max_column_preview(true) .max_columns_preview(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
.line_number(false) .line_number(false)
@ -2500,7 +2500,7 @@ but Doctor Watson has to have it taken out for him and dusted,
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.stats(true) .stats(true)
.max_columns(Some(46)) .max_columns(Some(46))
.max_column_preview(true) .max_columns_preview(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
.line_number(false) .line_number(false)
@ -2817,7 +2817,7 @@ Holmeses, success in the province of detective work must always
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.only_matching(true) .only_matching(true)
.max_columns(Some(10)) .max_columns(Some(10))
.max_column_preview(true) .max_columns_preview(true)
.column(true) .column(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
@ -2885,7 +2885,7 @@ Holmeses, success in the province of detective work must always
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.only_matching(true) .only_matching(true)
.max_columns(Some(10)) .max_columns(Some(10))
.max_column_preview(true) .max_columns_preview(true)
.column(true) .column(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
@ -2947,7 +2947,7 @@ Holmeses, success in the province of detective work must always
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.only_matching(true) .only_matching(true)
.max_columns(Some(50)) .max_columns(Some(50))
.max_column_preview(true) .max_columns_preview(true)
.column(true) .column(true)
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
@ -3171,7 +3171,7 @@ Holmeses, success in the province of detective work must always
let matcher = RegexMatcher::new(r"Sherlock|Doctor (\w+)").unwrap(); let matcher = RegexMatcher::new(r"Sherlock|Doctor (\w+)").unwrap();
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.max_columns(Some(67)) .max_columns(Some(67))
.max_column_preview(true) .max_columns_preview(true)
.replacement(Some(b"doctah $1 MD".to_vec())) .replacement(Some(b"doctah $1 MD".to_vec()))
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()
@ -3200,7 +3200,7 @@ Holmeses, success in the province of detective work must always
).unwrap(); ).unwrap();
let mut printer = StandardBuilder::new() let mut printer = StandardBuilder::new()
.max_columns(Some(43)) .max_columns(Some(43))
.max_column_preview(true) .max_columns_preview(true)
.replacement(Some(b"xxx".to_vec())) .replacement(Some(b"xxx".to_vec()))
.build(NoColor::new(vec![])); .build(NoColor::new(vec![]));
SearcherBuilder::new() SearcherBuilder::new()

View File

@ -583,7 +583,7 @@ pub fn all_args_and_flags() -> Vec<RGArg> {
flag_line_number(&mut args); flag_line_number(&mut args);
flag_line_regexp(&mut args); flag_line_regexp(&mut args);
flag_max_columns(&mut args); flag_max_columns(&mut args);
flag_max_column_preview(&mut args); flag_max_columns_preview(&mut args);
flag_max_count(&mut args); flag_max_count(&mut args);
flag_max_depth(&mut args); flag_max_depth(&mut args);
flag_max_filesize(&mut args); flag_max_filesize(&mut args);
@ -1490,7 +1490,7 @@ When this flag is omitted or is set to 0, then it has no effect.
args.push(arg); args.push(arg);
} }
fn flag_max_column_preview(args: &mut Vec<RGArg>) { fn flag_max_columns_preview(args: &mut Vec<RGArg>) {
const SHORT: &str = "Print a preview for lines exceeding the limit."; const SHORT: &str = "Print a preview for lines exceeding the limit.";
const LONG: &str = long!("\ const LONG: &str = long!("\
When the '--max-columns' flag is used, ripgrep will by default completely When the '--max-columns' flag is used, ripgrep will by default completely
@ -1501,16 +1501,16 @@ of the line exceeding the limit is not shown.
If the '--max-columns' flag is not set, then this has no effect. If the '--max-columns' flag is not set, then this has no effect.
This flag can be disabled with '--no-max-column-preview'. This flag can be disabled with '--no-max-columns-preview'.
"); ");
let arg = RGArg::switch("max-column-preview") let arg = RGArg::switch("max-columns-preview")
.help(SHORT).long_help(LONG) .help(SHORT).long_help(LONG)
.overrides("no-max-column-preview"); .overrides("no-max-columns-preview");
args.push(arg); args.push(arg);
let arg = RGArg::switch("no-max-column-preview") let arg = RGArg::switch("no-max-columns-preview")
.hidden() .hidden()
.overrides("max-column-preview"); .overrides("max-columns-preview");
args.push(arg); args.push(arg);
} }

View File

@ -778,7 +778,7 @@ impl ArgMatches {
.per_match(self.is_present("vimgrep")) .per_match(self.is_present("vimgrep"))
.replacement(self.replacement()) .replacement(self.replacement())
.max_columns(self.max_columns()?) .max_columns(self.max_columns()?)
.max_column_preview(self.max_column_preview()) .max_columns_preview(self.max_columns_preview())
.max_matches(self.max_count()?) .max_matches(self.max_count()?)
.column(self.column()) .column(self.column())
.byte_offset(self.is_present("byte-offset")) .byte_offset(self.is_present("byte-offset"))
@ -1177,8 +1177,8 @@ impl ArgMatches {
/// Returns true if and only if a preview should be shown for lines that /// Returns true if and only if a preview should be shown for lines that
/// exceed the maximum column limit. /// exceed the maximum column limit.
fn max_column_preview(&self) -> bool { fn max_columns_preview(&self) -> bool {
self.is_present("max-column-preview") self.is_present("max-columns-preview")
} }
/// The maximum number of matches permitted. /// The maximum number of matches permitted.

View File

@ -633,10 +633,10 @@ rgtest!(f993_null_data, |dir: Dir, mut cmd: TestCommand| {
// See: https://github.com/BurntSushi/ripgrep/issues/1078 // See: https://github.com/BurntSushi/ripgrep/issues/1078
// //
// N.B. There are many more tests in the grep-printer crate. // N.B. There are many more tests in the grep-printer crate.
rgtest!(f1078_max_column_preview1, |dir: Dir, mut cmd: TestCommand| { rgtest!(f1078_max_columns_preview1, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK); dir.create("sherlock", SHERLOCK);
cmd.args(&[ cmd.args(&[
"-M46", "--max-column-preview", "-M46", "--max-columns-preview",
"exhibited|dusted|has to have it", "exhibited|dusted|has to have it",
]); ]);
@ -647,10 +647,10 @@ sherlock:and exhibited clearly, with a label attached.
eqnice!(expected, cmd.stdout()); eqnice!(expected, cmd.stdout());
}); });
rgtest!(f1078_max_column_preview2, |dir: Dir, mut cmd: TestCommand| { rgtest!(f1078_max_columns_preview2, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK); dir.create("sherlock", SHERLOCK);
cmd.args(&[ cmd.args(&[
"-M43", "--max-column-preview", "-M43", "--max-columns-preview",
// Doing a replacement forces ripgrep to show the number of remaining // Doing a replacement forces ripgrep to show the number of remaining
// matches. Normally, this happens by default when printing a tty with // matches. Normally, this happens by default when printing a tty with
// colors. // colors.