Handle edge case in range_to_target() correctly.

This commit is contained in:
Nathan Vegdahl 2021-07-19 12:30:08 -07:00
parent b0311f4fc2
commit e98d669c30

View file

@ -285,7 +285,7 @@ impl CharHelpers for Chars<'_> {
// Find our target position(s).
let head_start = head;
while let Some(next_ch) = self.next() {
if reached_target(target, prev_ch.unwrap_or(next_ch), next_ch) {
if prev_ch.is_none() || reached_target(target, prev_ch.unwrap(), next_ch) {
if head == head_start {
anchor = head;
} else {