DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into find-change-change-find
moppeeer47589a8c848a
diff --cc crates/compose/src/grep.rsindex 0b4d2eca3,6f9e8f9e3..61546d162--- a/crates/compose/src/grep.rs+++ b/crates/compose/src/grep.rs@@@ -378,16 -385,17 +385,27 @@@ impl Grepself.re.find_iter(text).take(limit).map(|m| m.map(|m| m.range()).map_err(run_err)).collect()}+ /// The first match starting at or after byte `start`, with its replacement: `template`+ /// expanded as [`Self::replacements`] does.+ pub fn replacement_at(&self, text: &str, start: usize, template: &str) -> Result<Option<(Range<usize>, String)>, GrepError> {+ if start > text.len() || !text.is_char_boundary(start) {+ return Ok(None);+ }+ let Some(caps) = self.re.captures_from_pos(text, start).map_err(run_err)? else { return Ok(None) };+ Ok(caps.get(0).map(|m| (m.range(), fancy_regex::Expander::default().expansion(template, &caps))))+ }++ /// Non-empty matches in `text`, at most `limit` of them: an empty match styles nothing, so it+ /// doesn't count toward a GREP style's cap.+ pub fn find_nonempty(&self, text: &str, limit: usize) -> Result<Vec<Range<usize>>, GrepError> {+ self.re+ .find_iter(text)+ .filter(|m| !m.as_ref().is_ok_and(|m| m.range().is_empty()))+ .take(limit)+ .map(|m| m.map(|m| m.range()).map_err(run_err))+ .collect()+ }+/// Matches in `text` and their replacements, `template` expanded per match (`$1`…; see/// [`translate_replacement`]). Stops after the first match when `first_only`.pub fn replacements(&self, text: &str, template: &str, first_only: bool) -> Result<Vec<(Range<usize>, String)>, GrepError> {