Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-core/src/snippets/elaborate.rs')
| -rw-r--r-- | helix-core/src/snippets/elaborate.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/helix-core/src/snippets/elaborate.rs b/helix-core/src/snippets/elaborate.rs index b17c149f..09eee7e5 100644 --- a/helix-core/src/snippets/elaborate.rs +++ b/helix-core/src/snippets/elaborate.rs @@ -325,14 +325,14 @@ impl Transform { let mut buf = Tendril::new(); let it = self .regex - .captures_iter(doc.regex_input_at(range)) + .captures_iter(doc.regex_input_at_bytes(range)) .enumerate(); doc = doc.slice(range); let mut last_match = 0; for (_, cap) in it { // unwrap on 0 is OK because captures only reports matches let m = cap.get_group(0).unwrap(); - buf.extend(doc.byte_slice(last_match..m.start).chunks()); + buf.extend(doc.slice(last_match..m.start).chunks()); last_match = m.end; for fmt in &*self.replacement { match *fmt { @@ -341,12 +341,12 @@ impl Transform { } FormatItem::Capture(i) => { if let Some(cap) = cap.get_group(i) { - buf.extend(doc.byte_slice(cap.range()).chunks()); + buf.extend(doc.slice(cap.range()).chunks()); } } FormatItem::CaseChange(i, change) => { if let Some(cap) = cap.get_group(i).filter(|i| !i.is_empty()) { - let mut chars = doc.byte_slice(cap.range()).chars(); + let mut chars = doc.slice(cap.range()).chars(); match change { CaseChange::Upcase => to_upper_case_with(chars, &mut buf), CaseChange::Downcase => to_lower_case_with(chars, &mut buf), @@ -361,7 +361,7 @@ impl Transform { } } FormatItem::Conditional(i, ref if_, ref else_) => { - if cap.get_group(i).is_none_or(|mat| mat.is_empty()) { + if cap.get_group(i).map_or(true, |mat| mat.is_empty()) { buf.push_str(else_) } else { buf.push_str(if_) @@ -373,7 +373,7 @@ impl Transform { break; } } - buf.extend(doc.byte_slice(last_match..).chunks()); + buf.extend(doc.slice(last_match..).chunks()); buf } } |