Repository navigation
feat: open the typeahead picker on multi-character triggers - #3414
christianhg wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 7b5bf1f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bundle Stats✅ No significant changes. All scenario measurements (7)🗺️
Significant means at least 1.0 KB and 1% gzip, or at least 5 ms and 10% import time. |
The picker opened only when the inserted text equalled the trigger match (`event.textInserted !== lastMatch.text` in the trigger rule guard), which a multi-character trigger like `/\[\[/` can only satisfy when all its characters arrive in one insert. Typing `[` then `[` left the picker idle. The partial rule refused any match starting before the insertion unless the inserted text matched the partial pattern on its own, so an Android-style commit of `[foo` after an existing `[` was refused too. The trigger rule now also accepts a match that ends at the caret when the match text ends with the inserted text. The partial rule skips its starts-before-insertion refusal when the insertion lands inside the trigger part of the match, measured by matching the trigger pattern against the start of the match text. Neither change depends on the trigger length. Single-character triggers behave as before: a non-empty suffix of a one-character match is the match itself, and a one-character trigger that starts before the insertion cannot end after it. Typing `[[`, Escape, then `[` still does not reopen the picker, because the input rule finds only the first non-overlapping `[[`.
d2b52d1 to
7b5bf1f
Compare
Triggers of more than one character, such as
/\[\[/or/:::/, now open the picker when the character that completes them is typed:[followed by[opens it with an empty keyword, and typing on updates the keyword. Inserting[fooin one go after an existing[, as Android keyboards do when committing a word, opens the picker with the keywordfoo. Selecting a match replaces every trigger character along with the keyword, and with adelimitersuch as], typing[[foo]auto-completes an exact match.Until now the picker opened only when the inserted text equalled the trigger match, so a multi-character trigger worked when pasted in one go and never when typed. The trigger rule now also accepts a match that ends at the caret whose text ends with what was just inserted. The partial rule had its own refusal for matches that start before the insertion, which blocked the Android case where a keyboard commits
[fooafter an existing[. It now lets that through when the insertion lands inside the trigger part of the match. The trigger length comes from matching the existing trigger pattern against the start of the match text, the same way the keyword is already extracted, rather than a named group that could clash with groups in the user's own patterns.Single-character triggers are unchanged by construction: a non-empty suffix of a one-character match is the match itself, and a one-character trigger that starts before the insertion cannot end after it. Every existing test passes untouched. The new scenarios in
pattern-edge-cases.test.tsxreplace the test that pinned multi-character triggers as unsupported. Neither guard depends on the trigger length, and a/:::/scenario pins a three-character trigger. A/\w+/keyword variant pins the trigger rule change on its own, and the bulk[fooand[foo]inserts pin the partial rule change.One limit stays and is now documented in the README: typing
[[, Escape, then[does not reopen the picker, because the input rule finds only the first non-overlapping[[in[[[. A stale or dismissed first[does count when the second one is typed, which follows the rule that the character just typed completes the trigger.