mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-24 02:27:08 -06:00
Format Painter: walk only the paragraphs a text selection has
An unclamped hostile selection end (text.select caret [1e18, 0]) made covered_paragraphs iterate for effectively forever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
da3e89695f
commit
a5ca7d04b0
@@ -1178,7 +1178,8 @@ fn covered_paragraphs(s: &Session) -> Vec<usize> {
|
||||
let Some(t) = &st.selection.text else { return vec![] };
|
||||
let Some(body) = super::text::body_of(st, t) else { return vec![] };
|
||||
let (a, b) = t.ordered();
|
||||
(a.0..=b.0)
|
||||
// A hostile selection can point past the body: walk only the paragraphs it has.
|
||||
(a.0..=b.0.min(body.paragraphs.len().saturating_sub(1)))
|
||||
.filter(|&pi| {
|
||||
let Some(para) = body.paragraphs.get(pi) else { return false };
|
||||
let starts = pi > a.0 || a.1 == 0;
|
||||
|
||||
Reference in New Issue
Block a user