diff --git a/complete/_rg b/complete/_rg index df81790f..f91a31bc 100644 --- a/complete/_rg +++ b/complete/_rg @@ -47,7 +47,6 @@ _rg() { '--ignore-file=[specify additional ignore file]:file:_files' '(-v --invert-match)'{-v,--invert-match}'[invert matching]' '(-n -N --line-number --no-line-number)'{-n,--line-number}'[show line numbers]' - '(-N --no-line-number)--line-number-width=[specify width of displayed line number]:number of columns' '(-w -x --line-regexp --word-regexp)'{-x,--line-regexp}'[only show matches surrounded by line boundaries]' '(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes' '(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches' diff --git a/src/app.rs b/src/app.rs index 2c3bfe43..2cb2c468 100644 --- a/src/app.rs +++ b/src/app.rs @@ -475,23 +475,6 @@ impl RGArg { }); self } - - /// Indicate that any value given to this argument should be a valid - /// line number width. A valid line number width cannot start with `0` - /// to maintain compatibility with future improvements that add support - /// for padding character specifies. - fn line_number_width(mut self) -> RGArg { - self.claparg = self.claparg.validator(|val| { - if val.starts_with("0") { - Err(String::from( - "Custom padding characters are currently not supported. \ - Please enter only a numeric value.")) - } else { - val.parse::().map(|_| ()).map_err(|err| err.to_string()) - } - }); - self - } } // We add an extra space to long descriptions so that a black line is inserted @@ -535,7 +518,6 @@ pub fn all_args_and_flags() -> Vec { flag_ignore_file(&mut args); flag_invert_match(&mut args); flag_line_number(&mut args); - flag_line_number_width(&mut args); flag_line_regexp(&mut args); flag_max_columns(&mut args); flag_max_count(&mut args); @@ -1100,18 +1082,6 @@ terminal. args.push(arg); } -fn flag_line_number_width(args: &mut Vec) { - const SHORT: &str = "Left pad line numbers up to NUM width."; - const LONG: &str = long!("\ -Left pad line numbers up to NUM width. Space is used as the default padding -character. This has no effect if --no-line-number is enabled. -"); - let arg = RGArg::flag("line-number-width", "NUM") - .help(SHORT).long_help(LONG) - .line_number_width(); - args.push(arg); -} - fn flag_line_regexp(args: &mut Vec) { const SHORT: &str = "Only show matches surrounded by line boundaries."; const LONG: &str = long!("\ diff --git a/src/args.rs b/src/args.rs index 516a4d04..0c231d0f 100644 --- a/src/args.rs +++ b/src/args.rs @@ -56,7 +56,6 @@ pub struct Args { invert_match: bool, line_number: bool, line_per_match: bool, - line_number_width: Option, max_columns: Option, max_count: Option, max_filesize: Option, @@ -191,8 +190,7 @@ impl Args { .only_matching(self.only_matching) .path_separator(self.path_separator) .with_filename(self.with_filename) - .max_columns(self.max_columns) - .line_number_width(self.line_number_width); + .max_columns(self.max_columns); if let Some(ref rep) = self.replace { p = p.replace(rep.clone()); } @@ -401,7 +399,6 @@ impl<'a> ArgMatches<'a> { ignore_files: self.ignore_files(), invert_match: self.is_present("invert-match"), line_number: line_number, - line_number_width: try!(self.usize_of("line-number-width")), line_per_match: self.is_present("vimgrep"), max_columns: self.usize_of_nonzero("max-columns")?, max_count: self.usize_of("max-count")?.map(|n| n as u64), diff --git a/src/printer.rs b/src/printer.rs index 840c7c9a..fce6858c 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -99,10 +99,6 @@ pub struct Printer { path_separator: Option, /// Restrict lines to this many columns. max_columns: Option, - /// Width of line number displayed. If the number of digits in the - /// line number is less than this, it is left padded with - /// spaces. - line_number_width: Option } impl Printer { @@ -124,7 +120,6 @@ impl Printer { colors: ColorSpecs::default(), path_separator: None, max_columns: None, - line_number_width: None } } @@ -213,12 +208,6 @@ impl Printer { self } - /// Configure the width of the displayed line number - pub fn line_number_width(mut self, line_number_width: Option) -> Printer { - self.line_number_width = line_number_width; - self - } - /// Returns true if and only if something has been printed. pub fn has_printed(&self) -> bool { self.has_printed @@ -484,9 +473,6 @@ impl Printer { fn line_number(&mut self, n: u64, sep: u8) { let mut line_number = n.to_string(); - if let Some(width) = self.line_number_width { - line_number = format!("{:>width$}", line_number, width = width); - } self.write_colored(line_number.as_bytes(), |colors| colors.line()); self.separator(&[sep]); } diff --git a/tests/tests.rs b/tests/tests.rs index c9fa002f..b1b972cf 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -107,22 +107,6 @@ sherlock!(line_numbers, |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, expected); }); -sherlock!(line_number_width, |wd: WorkDir, mut cmd: Command| { - cmd.arg("-n"); - cmd.arg("--line-number-width").arg("2"); - let lines: String = wd.stdout(&mut cmd); - let expected = " 1:For the Doctor Watsons of this world, as opposed to the Sherlock - 3:be, to a very large extent, the result of luck. Sherlock Holmes -"; - assert_eq!(lines, expected); -}); - -sherlock!(line_number_width_padding_character_error, |wd: WorkDir, mut cmd: Command| { - cmd.arg("-n"); - cmd.arg("--line-number-width").arg("02"); - wd.assert_non_empty_stderr(&mut cmd); -}); - sherlock!(columns, |wd: WorkDir, mut cmd: Command| { cmd.arg("--column"); let lines: String = wd.stdout(&mut cmd);