summaryrefslogtreecommitdiffstats
path: root/src/search_buffer.rs
AgeCommit message (Collapse)Author
2017-04-05fix typo in commentKosta Welke
2017-03-31Enforce 79 column limit. Grr.Andrew Gallant
2017-02-18Tweak how binary files are handled internally.Andrew Gallant
This commit fixes two issues. The first issue is that if a file contained many NUL bytes without any LF bytes, then the InputBuffer would read the entire file into memory. This is not typically a problem, but if you run rg on /proc, then bad things can happen when reading virtual memory mapping files. Arguably, such files should be ignored, but we should also try to avoid exhausting memory too. We fix this by pushing the `-a/--text` flag option down into InputBuffer, so that it knows to stop immediately if it finds a NUL byte. The other issue this fixes is that binary detection is now applied to every buffer instead of just the first one. This helps avoid detecting too many files as plain text if the first parts of a binary file happen to contain no NUL bytes. This issue still persists somewhat in the memory map searcher, since we probably don't want to search the entire file upfront for NUL bytes before actually performing our search. Instead, we search the first 10KB for now. Fixes #52, Fixes #311
2016-12-23fix some clippy lints (#288)Leonardo Yvens
2016-11-20Completely re-work colored output and tty handling.Andrew Gallant
This commit completely guts all of the color handling code and replaces most of it with two new crates: wincolor and termcolor. wincolor provides a simple API to coloring using the Windows console and termcolor provides a platform independent coloring API tuned for multithreaded command line programs. This required a lot more flexibility than what the `term` crate provided, so it was dropped. We instead switch to writing ANSI escape sequences directly and ignore the TERMINFO database. In addition to fixing several bugs, this commit also permits end users to customize colors to a certain extent. For example, this command will set the match color to magenta and the line number background to yellow: rg --colors 'match:fg:magenta' --colors 'line:bg:yellow' foo For tty handling, we've adopted a hack from `git` to do tty detection in MSYS/mintty terminals. As a result, ripgrep should get both color detection and piping correct on Windows regardless of which terminal you use. Finally, switch to line buffering. Performance doesn't seem to be impacted and it's an otherwise more user friendly option. Fixes #37, Fixes #51, Fixes #94, Fixes #117, Fixes #182, Fixes #231
2016-11-19Add --files-without-matches flag.Daniel Luz
Performs the opposite of --files-with-matches: only shows paths of files that contain zero matches. Closes #138
2016-11-06Add -m/--max-count flag.Andrew Gallant
This flag limits the number of matches printed *per file*. Closes #159
2016-09-28Be better with short circuiting with --quiet.Andrew Gallant
It didn't make sense for --quiet to be part of the printer, because --quiet doesn't just mean "don't print," it also means, "stop after the first match is found." This needs to be wired all the way up through directory traversal, and it also needs to cause all of the search workers to quit as well. We do it with an atomic that is only checked with --quiet is given. Fixes #116.
2016-09-25Stop after first match is found with --quiet.Andrew Gallant
Fixes #77.
2016-09-24Add --files-with-matches flag.Andrew Schwartzmeyer
Closes #26. Acts like --count but emits only the paths of files with matches, suitable for piping to xargs. Both mmap and no-mmap searches terminate after the first match is found. Documentation updated and tests added.
2016-09-13Stream results when feasible.0.0.19Andrew Gallant
For example, when only a single file (or stdin) is being searched, then we should be able to print directly to the terminal instead of intermediate buffers. (The buffers are only necessary for parallelism.) Closes #4.
2016-09-10Rename search module to search_stream.Andrew Gallant
The name better reflects the difference between it and the search_buffer module.
2016-09-09Add integration tests.Andrew Gallant
2016-09-08Refactor how coloring is done.0.0.14Andrew Gallant
All in the name of appeasing Windows.
2016-09-07Hack in Windows console coloring.0.0.11Andrew Gallant
The code has suffered and needs refactoring/commenting. BUT... IT WORKS!
2016-09-06Add support for memory maps.Andrew Gallant
I though plain `read` had usurped them, but when searching a very small number of files, mmaps can be around 20% faster on Linux. It'd be really unfortunate to leave that on the table. Mmap searching doesn't support contexts yet, but we probably don't really care. And duplicating that logic doesn't sound fun. Without contexts, mmap searching is delightfully simple.