1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2024-12-12 19:18:24 +02:00
ripgrep/crates/printer
Andrew Gallant 94e4b8e301
printer: fix --vimgrep for multi-line mode
It turned out that --vimgrep wasn't quite getting the column of each
match correctly. Instead of printing column numbers relative to the
current line, it was printing column numbers as byte offsets relative to
where the match began. To fix this, we simply subtract the offset of the
line number from the beginning of the match. If the beginning of the
match came before the start of the current line, then there's really
nothing sensible we can do other than to use a column number of 1, which
we now document.

Interestingly, existing tests were checking that the previous behavior
was intended. My only defense is that I somehow tricked myself into
thinking it was a byte offset instead of a column number.

Kudos to @bfrg for calling this out in #1866:
https://github.com/BurntSushi/ripgrep/issues/1866#issuecomment-841635553
2021-05-15 08:27:59 -04:00
..
src printer: fix --vimgrep for multi-line mode 2021-05-15 08:27:59 -04:00
Cargo.toml deps: update base64 to 0.13.0 2020-11-02 10:52:51 -05:00
LICENSE-MIT repo: move all source code in crates directory 2020-02-17 19:24:53 -05:00
README.md doc: update CI links in crate READMEs 2020-11-16 19:07:16 -05:00
UNLICENSE repo: move all source code in crates directory 2020-02-17 19:24:53 -05:00

grep-printer

Print results from line oriented searching in a human readable, aggregate or JSON Lines format.

Build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/grep-printer

NOTE: You probably don't want to use this crate directly. Instead, you should prefer the facade defined in the grep crate.

Usage

Add this to your Cargo.toml:

[dependencies]
grep-printer = "0.1"

and this to your crate root:

extern crate grep_printer;