pub fn find_all(
buffer: &Buffer,
regex: &Regex,
cancel: &CancellationToken,
) -> CoreResult<Vec<Range>>Expand description
Find every occurrence of the regex in the buffer. Returns the positional ranges in left-to-right order. Empty for matchless patterns and patterns whose minimum length exceeds the buffer.
Walks the rope’s chunk iterator – never allocates the whole
buffer text. Per-call cost on literal patterns is dominated by
the SIMD prefilter via the regex crate’s literal extraction.
cancel is polled between matches and at chunk boundaries
inside the inner walks. A flipped token short-circuits with
CoreError::Cancelled; partial results are discarded.
Matches never overlap: scanning resumes at the end of each match (one UTF-8 scalar further for a zero-width match).
§Examples
use fancy_regex::Regex;
use lattice_core::Buffer;
use lattice_core::protocol::CancellationToken;
use lattice_core::protocol::position::{Position, Range};
use lattice_core::search::find_all;
let buf = Buffer::from_text("foo bar\nbaz foo\n");
let re = Regex::new("fo+")?;
let hits = find_all(&buf, &re, &CancellationToken::never())?;
assert_eq!(
hits,
[
Range::new(Position::new(0, 0), Position::new(0, 3)),
Range::new(Position::new(1, 4), Position::new(1, 7)),
],
);