Panics · P22 Collaboration: marks outside their text stay out under the owner's index; accept answers None; zero reactions and stale masked offsets hold

This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 00:17:15 -04:00
1 parent 19b0b2997a
commit 9eab2019a8
9 files changed
+215 -35

No files matched your search

+10 -2
View File
@@ -261,7 +261,10 @@ const BASE: &str = "A lift blends color toward white. Half a lift sits midway be
fn applied(base: &str, suggestions: Vec<Suggestion>) -> String {
let (mut text, mut left) = (base.to_string(), suggestions);
while !left.is_empty() {
(text, left) = accept(&text, &left, 0);
let Some(taken) = accept(&text, &left, 0) else {
break;
};
(text, left) = taken;
}
text
}
@@ -306,11 +309,16 @@ pub fn changes(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
let pending = suggested(&base_text, field.read(cx).text(), &you());
match decision {
Decision::Accept(ix) => {
set(&decided, accept(&base_text, &pending, ix).0, cx)
if let Some((text, _)) = accept(&base_text, &pending, ix) {
set(&decided, text, cx)
}
}
Decision::AcceptAll => set(&decided, applied(&base_text, pending), cx),
Decision::Reject(ix) => {
let mut rest = pending;
if ix >= rest.len() {
return;
}
rest.remove(ix);
let text = applied(&base_text, rest);
field.update(cx, |input, cx| input.set_text(text, cx));