mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-06-14 22:15:13 +02:00
printer: trim line terminator before doing replacements
This is basically the same bug as #1401, but applied to replacements instead of --only-matching. Fixes #1739
This commit is contained in:
@ -68,7 +68,13 @@ impl<M: Matcher> Replacer<M> {
|
||||
subject = &subject[..range.end + MAX_LOOK_AHEAD];
|
||||
}
|
||||
} else {
|
||||
subject = &subject[..range.end];
|
||||
// When searching a single line, we should remove the line
|
||||
// terminator. Otherwise, it's possible for the regex (via
|
||||
// look-around) to observe the line terminator and not match
|
||||
// because of it.
|
||||
let mut m = Match::new(0, range.end);
|
||||
trim_line_terminator(searcher, subject, &mut m);
|
||||
subject = &subject[..m.end()];
|
||||
}
|
||||
{
|
||||
let &mut Space { ref mut dst, ref mut caps, ref mut matches } =
|
||||
|
Reference in New Issue
Block a user