fix: open the context popup from a selection made with the keyboard - #173
Merged
Conversation
Opening from the plugin update path rather than a new key binding covers `Select all` too, which arrives as an ordinary selection transaction with no gesture of its own.
Deriving the end of a selection gesture from the keystroke cannot serve `Select all`: extending afterwards re-anchors the selection at the text start, so the dismissal would lift on the first `Shift+Arrow`. Collapsing is the one thing no selection survives, and holding the dismissal until then is conservative in the direction the user asked for.
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
A selection made from the keyboard now opens the context popup, as a pointer selection already did. The documents described that behavior for any selection; only the pointer had it.
updatepath, which every selection change already reaches. That covers a selection extended withShift+ArroworMod+Shift+Arrowand one made whole bySelect all, without a key binding of its own.pointersource. Akeyboardrequest moves focus into the popup, which would end the gesture it just opened for; leaving focus in the editor keeps further presses extending the selection, and an open popup stays open rather than reopening.Escapelatches the dismissal, since it closes the popup without disturbing the selection and the next keystroke would otherwise reopen it. The latch releases when the selection collapses, or when something deliberately opens the popup again.mousedownhandler suppresses auto-open for the length of a drag, so the pointer path still opens on release only.docs/specification.mdgains the open-from-selection andEscapedismissal rules;docs/reference.mdnames the trigger as a pointer or keyboard selection.Related Issue
Closes #164
Verification
Added to
contextPopup.test.tsx: opening from a selection extended withShift+ArrowandMod+Shift+Arrowand fromSelect all, focus staying on the editor, one popup staying open while the selection grows, the dismissal holding while the selection grows and until it collapses afterSelect all, and a pointer selection opening only on release.Manually verified in the desktop app on Windows:
Shift+RightandMod+Shift+Rightopens the popup, which stays open while the caret keeps extending.Mod+Aopens it with focus left in the editor.Escapemid-gesture keeps it dismissed while the selection grows, and it opens again once the selection collapses.Shift+F10and theMenukey still open it with focus, typing still dismisses it, and pointer drag-selection still opens on release.Notes
Select all, because extending afterwards re-anchors the selection at the text start and would lift the dismissal on the firstShift+Arrow. Collapse-only holds the dismissal longer than the issue requires, and both criteria are "stays dismissed". The cost is thatMod+Astraight after anEscapedoes not reopen the popup until the selection collapses."leaves an unmodified F10 to the rest of the editor"selects text before pressing F10, and that selection now opens the popup on its own. Its mock is cleared after the selection so the assertion still tests only what F10 adds; the assertion is unchanged.