summaryrefslogtreecommitdiffstats
path: root/crates/printer/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/printer/src/util.rs')
-rw-r--r--crates/printer/src/util.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/printer/src/util.rs b/crates/printer/src/util.rs
index e19d4a8b..68693d34 100644
--- a/crates/printer/src/util.rs
+++ b/crates/printer/src/util.rs
@@ -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 } =