Expand description
Find — the search core.
Search is a literal substring with an ASCII case-fold toggle, or — behind
the whole-word / regex options — a line-scoped pattern. (The private
Matcher type carries the full rationale for why a line, and not a byte
window, is the unit there.) The search bar is app-side chrome; this module
owns only the match model, the scan, and what a replacement means.
The one design choice: the match set lives only in the decoration store
— the sorted FindMatch decorations ARE the match set, in document order
(one fact, one owner). FindState holds the query and the scan
bookkeeping, never a shadow list of handles. The set is kept current
eagerly: every committed transaction (forward edit, undo, redo — they
share the same view-rebase path) runs FindState::on_commit, a windowed
repair around each edit, so consumers never see a stale match. The one
remaining debounced path is the capped-set refill
(FindState::maybe_rescan).
Documented, test-pinned relaxation: for needles that cannot overlap
themselves the repaired set is byte-identical to a fresh scan; a
self-overlapping needle ("aa") repairs to a maximal valid
non-overlapping set whose phase near the edit may differ from the greedy
full scan until the next query change.
Structs§
- Find
Query - An active find query: the pattern plus its option flags.
- Find
State - The search view-state: the active query, the active match’s decoration id, and the coverage/cap bookkeeping.
Constants§
- FIND_
MATCH_ CAP - The scan stops after this many matches and records
capped— cheap insurance against a pathological query. A capped set is a prefix of the document: everything up toFindState’s coverage frontier is exact, nothing beyond it is represented.
Functions§
- default_
find_ debounce - Debounce window (ms) for the capped-set refill — a user-facing default,
exported as a
pub fn. This is the ONLY debounced find path: ordinary edits repair the match set eagerly at the commit. - scan
- Every non-overlapping match of
queryintext, leftmost-first, as byte spans; theboolis whether the scan hitFIND_MATCH_CAP.