Behaviour SwRS-MDOKFSTUDIO-PALETTE-240
The slash query ranks matches and leaves loose matches to the text
When the writer types a query after the slash, the extension SHALL narrow the list at each edit to the commands whose label or alias matches it, ignoring case, ranked exact first, then prefix, word start, contained text and a tight subsequence of three or more letters that starts at a word start (the command of the MyST group first in MyST mode), light the first entry, and leave Enter and Tab to the text when the best match is only a loose one and the highlight was not moved.
Step 2 of path 1 in StRS-MDOKFSTUDIO-PALETTE-015: from “The slash menu lists the commands of the mode” to “The list is narrowed to the query”.
Scenarios 5
The situations the tests check; open one to read it.
nominalRanking
Giventhe entries Zebra Alpha, Alpine and Other with the alias alp
Whenalp is typed
Thenthe order is Other, Alpine, Zebra Alpha
| Match of the query on the label or an alias | Rank |
|---|---|
| exact (an exact label scores 1010, an exact alias 1000, because a label gets 10 more than an alias) | first |
| prefix | after exact |
| start of a later word | after prefix |
| contained text | after word start |
| tight subsequence of three or more letters that starts at a word start | last |
| ties | keep the order of the palette |
boundaryScattered letters and short queries
Giventhe entry Horizontal rule
Whenhz is typed
Thennothing matches
| Query | Outcome |
|---|---|
| one or two letters that are not a prefix, a word start or contained text (hz) | nothing matches; a query of one or two letters never matches by subsequence |
| three or more letters packed tightly from a word start (cbl for Code block) | matches by subsequence |
nominalIn MyST mode the MyST command wins a near tie
Giventhe MyST mode
Whennote is typed, then table is typed
Thenthe MyST admonition Note is listed before the GitHub alert, and the Table command stays first
| Query in MyST mode | Outcome |
|---|---|
| three or more letters, score of 1000 or more (exact) | a command of the MyST group gets 5 points before an equivalent command of another group |
| three or more letters, score from 400 to 999 | a command of the MyST group gets 8 points |
| exact label or clearly better prefix of another command (table, tab) | keeps its place |
| one or two letters (/h, and /h1 for Heading) | no bonus; Heading is found first |
nominalTyping narrows the list and resets the highlight
Givenan open menu with the third entry lit
Whenthe writer types a letter, then presses Backspace back to the query t
Thenthe list narrows and the first entry is lit, and with the shorter query the full list shows again and the first entry is lit
| Edit | Outcome |
|---|---|
| a letter typed after the slash | the list narrows to the matches and the first entry is lit |
| Backspace inside the query | the list is re-read from the text between the slash and the caret, widens and the first entry is lit |
boundaryA loose best match leaves Enter and Tab to the text
Giventhe text box with / and the query ori
Whenthe writer presses Enter, or moves the highlight with an arrow and then presses Enter
Thenthe menu closes and Enter inserts a line break as usual, or the lit command runs
| State | Outcome |
|---|---|
| best match with a score below 600 (letters inside a word or scattered letters), highlight not moved | the menu closes; Enter and Tab are left to the text |
| the same, highlight moved with an arrow | the lit command runs |
| best match with a score of 600 or more | Enter and Tab apply the lit command |
| Shift+Enter | always stays text |