Handle edge case in `range_to_target()` correctly.

pull/376/head
Nathan Vegdahl 3 years ago
parent b0311f4fc2
commit e98d669c30

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

Loading…
Cancel
Save