Merge PR #813: engine: a hostile text selection can't drive paragraph commands past the body

This commit is contained in:
aiongg
2026-10-24 06:15:03 +00:00
3 changed files with 36 additions and 6 deletions
+2 -1
View File
@@ -692,7 +692,8 @@ fn case(s: &mut Session, p: &Value) -> Result<Value> {
}
let m = if mode == "cycle" { ed::next_case(&ed::text_range(&body, a, b)).to_string() } else { mode.clone() };
super::text::edit_text(s, move |body, t| {
for pi in a.0..=b.0 {
let last = body.paragraphs.len().saturating_sub(1);
for pi in a.0..=b.0.min(last) {
let Some(para) = body.paragraphs.get_mut(pi) else { continue };
let n = para.char_len();
let from = if pi == a.0 { a.1 } else { 0 };