thing-tui: pin that a drop unregisters only its own guard
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 2m18s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 2m4s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-29 02:16:16 +01:00
commit e333cb8f9c

View file

@ -296,3 +296,17 @@ fn an_error_mid_draw_does_not_leave_the_synchronized_update_open() {
let end = bytes.rfind("\x1b[?2026l").expect("the restore closes the open update");
assert!(end < bytes.rfind(LEAVE).unwrap(), "closed before the alternate screen is left");
}
#[test]
fn dropping_one_guard_leaves_the_others_registered() {
let (kept, dropped) = (Shared::default(), Shared::default());
let other = Terminal::start(dropped.clone(), false).unwrap();
let live = guard(&kept);
drop(other);
let caught = catch_unwind(AssertUnwindSafe(move || {
let _live = live;
panic!("forced with a guard that outlived another");
}));
assert!(caught.is_err());
assert_eq!(count(&at_hand_over().expect("hook ran"), LEAVE), 1, "the surviving guard is still restored by the hook");
}