thing-tui: pin that a drop unregisters only its own guard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6f884075d7
commit
e333cb8f9c
1 changed files with 14 additions and 0 deletions
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue