mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-19 09:02:15 +02:00
Enforce 79 column limit. Grr.
This commit is contained in:
parent
1425d6735e
commit
fc975af8e9
11
src/app.rs
11
src/app.rs
@ -388,10 +388,11 @@ lazy_static! {
|
||||
"Limit the number of matching lines per file searched to NUM.");
|
||||
doc!(h, "max-filesize",
|
||||
"Ignore files larger than NUM in size.",
|
||||
"Ignore files larger than NUM in size. Does not ignore directories. \
|
||||
"Ignore files larger than NUM in size. Does not ignore \
|
||||
directories. \
|
||||
\n\nThe input format accepts suffixes of K, M or G which \
|
||||
correspond to kilobytes, megabytes and gigabytes. If no suffix is \
|
||||
provided the input is treated as bytes. \
|
||||
correspond to kilobytes, megabytes and gigabytes. If no suffix \
|
||||
is provided the input is treated as bytes. \
|
||||
\n\nExample: --max-filesize 50K or --max-filesize 80M");
|
||||
doc!(h, "maxdepth",
|
||||
"Descend at most NUM directories.",
|
||||
@ -496,8 +497,8 @@ lazy_static! {
|
||||
permits specifying one or more other type names (separated by a \
|
||||
comma) that have been defined and its rules will automatically \
|
||||
be imported into the type specified. For example, to create a \
|
||||
type called src that matches C++, Python and Markdown files, one \
|
||||
can use:\n\n\
|
||||
type called src that matches C++, Python and Markdown files, \
|
||||
one can use:\n\n\
|
||||
--type-add 'src:include:cpp,py,md'\n\n\
|
||||
Additional glob rules can still be added to the src type by \
|
||||
using the --type-add flag again:\n\n\
|
||||
|
@ -837,7 +837,7 @@ impl<'a> ArgMatches<'a> {
|
||||
let caps = try!(re.captures(&max_filesize)
|
||||
.ok_or("invalid format for max-filesize argument"));
|
||||
|
||||
let value = try!(caps[1].parse::<u64>().map_err(|err| err.to_string()));
|
||||
let value = try!(caps[1].parse::<u64>().map_err(|err|err.to_string()));
|
||||
let suffix = caps.get(2).map(|x| x.as_str());
|
||||
|
||||
match suffix {
|
||||
|
@ -447,7 +447,8 @@ mod tests {
|
||||
test_trans_simple!(trans_simple_utf16be, "utf-16be", b"\x04\x16", "Ж");
|
||||
test_trans_simple!(trans_simple_chinese, "chinese", b"\xA7\xA8", "Ж");
|
||||
test_trans_simple!(trans_simple_korean, "korean", b"\xAC\xA8", "Ж");
|
||||
test_trans_simple!(trans_simple_big5_hkscs, "big5-hkscs", b"\xC7\xFA", "Ж");
|
||||
test_trans_simple!(
|
||||
trans_simple_big5_hkscs, "big5-hkscs", b"\xC7\xFA", "Ж");
|
||||
test_trans_simple!(trans_simple_gbk, "gbk", b"\xA7\xA8", "Ж");
|
||||
test_trans_simple!(trans_simple_sjis, "sjis", b"\x84\x47", "Ж");
|
||||
test_trans_simple!(trans_simple_eucjp, "euc-jp", b"\xA7\xA8", "Ж");
|
||||
|
@ -153,9 +153,6 @@ impl<W: WriteColor> Printer<W> {
|
||||
|
||||
/// Replace every match in each matching line with the replacement string
|
||||
/// given.
|
||||
///
|
||||
/// The replacement string syntax is documented here:
|
||||
/// https://doc.rust-lang.org/regex/regex/bytes/struct.Captures.html#method.expand
|
||||
pub fn replace(mut self, replacement: Vec<u8>) -> Printer<W> {
|
||||
self.replace = Some(replacement);
|
||||
self
|
||||
@ -290,7 +287,8 @@ impl<W: WriteColor> Printer<W> {
|
||||
re.replace_all(&buf[start..end], replacer)
|
||||
};
|
||||
if self.max_columns.map_or(false, |m| line.len() > m) {
|
||||
let msg = format!("[Omitted long line with {} replacements]", count);
|
||||
let msg = format!(
|
||||
"[Omitted long line with {} replacements]", count);
|
||||
self.write_colored(msg.as_bytes(), |colors| colors.matched());
|
||||
self.write_eol();
|
||||
return;
|
||||
@ -319,7 +317,8 @@ impl<W: WriteColor> Printer<W> {
|
||||
let mut last_written = 0;
|
||||
for m in re.find_iter(buf) {
|
||||
self.write(&buf[last_written..m.start()]);
|
||||
self.write_colored(&buf[m.start()..m.end()], |colors| colors.matched());
|
||||
self.write_colored(
|
||||
&buf[m.start()..m.end()], |colors| colors.matched());
|
||||
last_written = m.end();
|
||||
}
|
||||
self.write(&buf[last_written..]);
|
||||
|
@ -3,8 +3,8 @@ The `search_buffer` module is responsible for searching a single file all in a
|
||||
single buffer. Typically, the source of the buffer is a memory map. This can
|
||||
be useful for when memory maps are faster than streaming search.
|
||||
|
||||
Note that this module doesn't quite support everything that `search_stream` does.
|
||||
Notably, showing contexts.
|
||||
Note that this module doesn't quite support everything that `search_stream`
|
||||
Notdoes. ably, showing contexts.
|
||||
*/
|
||||
use std::cmp;
|
||||
use std::path::Path;
|
||||
|
Loading…
x
Reference in New Issue
Block a user