Skip to main content

Module find_replace

Module find_replace 

Source
Expand description

The pure half of find-and-replace: compiling a find pattern, counting its matches, expanding a replacement, and building the substituted lines a replace preview draws.

Nothing here touches a TextArea, a Frame, or the editor — it is &[String] in, values out, so the semantics that are easy to get wrong (smartcase, capture gating, span remapping) are testable with literals.

Matching is per line, because that is what the textarea’s search engine does: a pattern can never span a newline, and ^/$ anchor per line.

Structs§

FindPattern
A compiled find pattern, plus the case decision that produced it.
Preview
The result of substituting every match into a copy of the buffer.
PreviewSpan
One match rewritten inside a previewed line, in that line’s preview coordinates (char columns), not the buffer’s.

Functions§

build_preview
Build the replace preview: every match replaced, plus where each replacement landed so the renderer can colour it.
replace_all
Rewrite every match in lines, returning the new lines and how many matches were rewritten. The replace all primitive.