diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-04-13 18:35:24 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-04-14 19:29:27 -0400 |
commit | ece1f50cfe49fea324d96f97a2ae00ebbd0cad03 (patch) | |
tree | 8615570232a16f572702619333b446a0a530772c /tests | |
parent | a7d26c8f144a4957b75f71087a66692d0b25759a (diff) |
printer: support previews for long lines
This commit adds support for showing a preview of long lines. While the
default still remains as completely suppressing the entire line, this
new functionality will show the first N graphemes of a matching line,
including the number of matches that are suppressed.
This was unfortunately a fairly invasive change to the printer that
required a bit of refactoring. On the bright side, the single line
and multi-line coloring are now more unified than they were before.
Closes #1078
Diffstat (limited to 'tests')
-rw-r--r-- | tests/feature.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/feature.rs b/tests/feature.rs index a3e2f441..6ee2bf87 100644 --- a/tests/feature.rs +++ b/tests/feature.rs @@ -630,6 +630,41 @@ rgtest!(f993_null_data, |dir: Dir, mut cmd: TestCommand| { eqnice!(expected, cmd.stdout()); }); +// See: https://github.com/BurntSushi/ripgrep/issues/1078 +// +// N.B. There are many more tests in the grep-printer crate. +rgtest!(f1078_max_column_preview1, |dir: Dir, mut cmd: TestCommand| { + dir.create("sherlock", SHERLOCK); + cmd.args(&[ + "-M46", "--max-column-preview", + "exhibited|dusted|has to have it", + ]); + + let expected = "\ +sherlock:but Doctor Watson has to have it taken out for [... omitted end of long line] +sherlock:and exhibited clearly, with a label attached. +"; + eqnice!(expected, cmd.stdout()); +}); + +rgtest!(f1078_max_column_preview2, |dir: Dir, mut cmd: TestCommand| { + dir.create("sherlock", SHERLOCK); + cmd.args(&[ + "-M43", "--max-column-preview", + // Doing a replacement forces ripgrep to show the number of remaining + // matches. Normally, this happens by default when printing a tty with + // colors. + "-rxxx", + "exhibited|dusted|has to have it", + ]); + + let expected = "\ +sherlock:but Doctor Watson xxx taken out for him and [... 1 more match] +sherlock:and xxx clearly, with a label attached. +"; + eqnice!(expected, cmd.stdout()); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/1138 rgtest!(f1138_no_ignore_dot, |dir: Dir, mut cmd: TestCommand| { dir.create_dir(".git"); |