forge
Explore
Log in

Don't you dare go Hollow

The dispatch needle is the statement, not any lookup

Browse files at this commit

44ab0de3ad38390e77c4b730d3e0495706baae3aAhmet Kaan GümüşParent: 87eae13
  • test
    • the dispatch needle is the statement, not any lookup
Show full message
🐛 test(keys): the dispatch needle is the statement, not any lookup

The needle was satisfied by the hold gate's own `this.keymap.lookup(key, ctrl)` at the top of the handler, so a dispatch that resolved the action another way kept the test green (verifier finding H3). The statement is now read on its own -- from its `if let Some(action) = ...` to its opening brace -- and must contain the `card_safe_action(` call that decides the stroke.
crates/app/src/tests/view.rsmodified+14 -0
@@ -1107,6 +1107,20 @@ fn an_open_card_does_not_swallow_the_document_chords() {
1107 stance_rs[..dispatch].contains("this.keymap.lookup(key, ctrl)"),1107 stance_rs[..dispatch].contains("this.keymap.lookup(key, ctrl)"),
1108 "the dispatch no longer goes through the keymap, so a rebind would leave it behind"1108 "the dispatch no longer goes through the keymap, so a rebind would leave it behind"
1109 );1109 );
1110+ // The *statement* that dispatches, not just some `keymap.lookup` before it:
1111+ // the hold gate at the top of the handler resolves the same pair, so a needle
1112+ // that only asks for the lookup is satisfied by a dispatch resolving the
1113+ // action some other way entirely.
1114+ let resolve = stance_rs
1115+ .find("if let Some(action) = this.keymap.lookup(key, ctrl)")
1116+ .expect("the dispatch no longer resolves an action through the keymap");
1117+ let stmt = &stance_rs[resolve..];
1118+ let stmt = &stmt[..stmt.find('{').expect("the dispatch statement has no block")];
1119+ assert!(
1120+ stmt.contains("card_safe_action("),
1121+ "the dispatch resolves an action and never asks whether a card may take \
1122+ it, so an open card eats the document chords again"
1123+ );
1110 for (guard, label) in [1124 for (guard, label) in [
1111 ("if this.param_card_key(", "the cards' own key branches"),1125 ("if this.param_card_key(", "the cards' own key branches"),
1112 ("if this.card_open()", "the blanket modal guard"),1126 ("if this.card_open()", "the blanket modal guard"),