refactor(engine): leave the menu accept rule in one place - #1210
Open
shreeve wants to merge 1 commit into
Open
Conversation
`Enter` grew a guard that accepts an open menu's selection, and `MenuAccept` landed with the same rule written a second way: the guard filters on `is_active() && !get_values().is_empty()`, `MenuAccept` finds the first active menu and checks emptiness after. Nothing can tell them apart today, since `ReedlineEvent::Menu` will not activate a second menu while one is open, but the two are already spelled differently and only one of them is the one anybody reads. `Enter`, `Submit` and `SubmitOrNewline` now offer an open menu first refusal and carry on to the submit path when it declines, which is what the guard was arranging for. The rule lives in the `MenuAccept` arm, and the reasoning that used to sit above `Enter` describing the guard sits with it. The behavior is unchanged, and the new cases pin it from both sides: all three events accept an open menu, and all three run the line once the menu has nothing to offer. They pass on the two-rule version too.
shreeve
force-pushed
the
menu-accept-is-the-one-rule
branch
from
September 9, 2026 12:42
93a7c2e to
2a043ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The follow-up from #1175, as suggested there.
Entergrew a guard that accepts an open menu's selection, and #1203 landedMenuAcceptcarrying the same rule a second time. They are not even spelled thesame way: the guard filters on
is_active() && !get_values().is_empty(), whileMenuAcceptfinds the first active menu and checks emptiness afterwards. Thosedisagree when the first active menu is the empty one — unreachable today, since
ReedlineEvent::Menurefuses to activate whileactive_menu()isSome, but it isthe drift worth removing rather than documenting.
Enter,SubmitandSubmitOrNewlinenow tryMenuAcceptfirst and carry on tothe submit path when it declines, which is what the guard was arranging for. The
guarded arm goes away, the rule lives in the
MenuAcceptarm, and each submit armsays plainly that a menu gets first refusal.
Behavior
Unchanged.
MenuAcceptreportsInapplicablefor exactly the cases the guardexcluded — no menu open, or an open menu with nothing to accept — and the
delegation sits at the top of each arm, ahead of the bashisms and abbreviation
expansion, so the ordering is what it was.
Worth noting the guard covered
SubmitandSubmitOrNewlineas well asEnter,and nothing tested that. It does now.
One thing this surfaced, not fixed here
MenuAcceptdoes not checkresults_are_provisional(), so accepting over stalesuggestions splices nothing — the span belongs to another line and is refused
downstream — while
Deactivatestill runs and the arm still reportsHandled. Adead key, reachable with an async completer.
decide_menu_completionandMenuNextboth guard this explicitly and their comments say exactly why.
This is not a regression: the deleted guard had no provisional check either, so
Enterbehaved this way already. But this PR is what makesMenuAcceptthe singlepath, and the rule it now owns is missing a check its two siblings have. Happy to fix
it in a follow-up, or fold it in here if you would rather it not land as-is.
Tests
Two
rstestcases over all three events:every_submit_event_accepts_an_open_menu— the menu takes the keypress, closes,and its selection reaches the buffer
every_submit_event_passes_an_empty_menu— once the menu has nothing to offer,the line runs
Both pass on the two-rule version as well, which is the point: they pin the
behavior, and this does not move it.
cargo fmt --checkandcargo clippy --all-targets --all-features -- -D warningsare clean; the suite passes with default and with all features.