From b3e18150cca8d9137e93fffbe3f5a81b67924177 Mon Sep 17 00:00:00 2001 From: Levi Neuwirth Date: Thu, 23 Jul 2026 19:33:35 -0400 Subject: [PATCH] test(fold): make the inactive-buffer unfold guard actually bite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bite-verification found the Q#FD19 active-window-buffer requirement's test vacuous: `other` held no fold, so removing the guard changed nothing — `unfold_containing` on a store-less buffer is a no-op either way. The guard's real job is to stop the invoking frontend's POINT from naming a place in a buffer it is not looking at, so the fixture now gives `other` a fold whose range contains the active window's cursor byte. Reverting the guard now opens it (0 != 1). Verified: with `if window.buffer_id != id { return; }` replaced by a no-op, the test fails on a clean assertion. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q5BkezMppbpCgGAYk2ftxV --- tests/folding_stage2_acceptance.rs | 32 ++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/folding_stage2_acceptance.rs b/tests/folding_stage2_acceptance.rs index 4f1a657..aaf785c 100644 --- a/tests/folding_stage2_acceptance.rs +++ b/tests/folding_stage2_acceptance.rs @@ -917,18 +917,42 @@ fn an_interactive_edit_to_an_inactive_buffer_does_not_unfold() { let (s, _id) = seeded(); let mut s = s; fold_active(&s, 2, 5); - set_cursor(&s, end_of(4)); - // A second, NOT-displayed buffer; the command edits that one. + set_cursor(&s, end_of(4)); // byte 19, inside the ACTIVE buffer's fold + + // A second, NOT-displayed buffer, deliberately shaped so the active + // window's cursor byte falls inside a fold of ITS OWN: without the + // active-window-buffer requirement the widening would anchor the + // wrong buffer's folds on this frontend's point and open it. exec( &s, - "other = pmacs.buffer.from_bytes('other.txt', 'aaa\\nbbb\\n')", + "other = pmacs.buffer.from_bytes('other.txt', 'aaa\\nbbb\\nccc\\nddd\\neee\\n')", ); + let other_folded: bool = eval( + &s, + "return pmacs.fold.fold(other, { start = 3, ['end'] = 19 })", + ); + assert!(other_folded); + let other_folds = |s: &EditorState| -> usize { + let core = s.core.borrow(); + let registry = core.registry.clone(); + let reg = registry.borrow(); + let id = reg.find_by_name("other.txt").expect("other.txt"); + s.fold_registry.folds(id).len() + }; + assert_eq!(other_folds(&s), 1); + define(&s, "test.other", "other:insert(0, 'q')"); m_x(&mut s, "test.other"); assert_eq!( fold_count(&s), 1, - "an explicit inactive-buffer mutation stays programmatic" + "the active buffer was not edited, so its fold stands" + ); + assert_eq!( + other_folds(&s), + 1, + "an explicit inactive-buffer mutation stays programmatic — the \ + invoking frontend's point does not name a place in THAT buffer" ); }