Skip to main content

scan

Function scan 

Source
pub fn scan(text: &str, query: &FindQuery) -> (Vec<Range<u32>>, bool)
Expand description

Every non-overlapping match of query in text, leftmost-first, as byte spans; the bool is whether the scan hit FIND_MATCH_CAP.

The query’s options pick the matcher. Plain text takes a literal byte-wise substring scan — the next probe starts at the previous match’s end (non-overlapping), case fold is ASCII only, byte-wise is exact for the ASCII DSL, and a multi-byte needle is out of scope. whole_word / regex take the line-scoped engine, fed one line at a time so a match never crosses a newline. An empty literal query yields no matches (never match-all); an unfinished regex yields none until it parses.

The pure whole-text scan the tests use as the oracle. The live paths (the query-change full scan, the capped refill, the per-edit window repairs) share its matcher rather than calling it directly, so the match rules cannot fork. Case-sensitive literal search rides memchr::memmem; the fold path probes the needle’s first byte’s two case forms via memchr2 — both bit-identical to the naive reference scan (pinned by scan_equals_the_naive_oracle).