Behaviour SwRS-MDOKFSTUDIO-GFM-041
Choosing an option moves the (x)
When a writer clicks or presses Space or Enter on an unselected option of a radio group, the extension SHALL write '(x)' on that option and '( )' on the previously selected one as one undo step, and restore the previous selection with the reason next to the option when the host refuses the choice.
Step 2 of path 1 in StRS-MDOKFSTUDIO-GFM-005: from “The items are shown as a radio group” to “The chosen option is selected”.
Scenarios 3
The situations the tests check; open one to read it.
nominalA click moves the selection in the source
boundaryClicks and keys that write nothing or normalise
| Input | Outcome |
|---|---|
| a click on the only selected option | no message, no write |
| two '(x)' in the source, then a click on one option | one write that leaves '(x)' on the clicked option only |
| ArrowDown or ArrowRight, ArrowUp or ArrowLeft, Home, End on a focused option | the focus moves to the next, previous (wrapping), first or last option of the group, which becomes its tab stop; nothing is written or selected |
| Space or Enter on a focused option | selects it and writes, as a click does; the key neither scrolls the page nor reaches the block keys; after the choice, once the content patch is applied, the focus is on the option of the same source line and column (also after a click), without scrolling |
| a content patch (an external rewrite) while no option has the focus | no option takes the focus |
| a click while a choice of the group waits for the host | prevented, no second message |
| an option without a valid line or column, or a group of fewer than two options | prevented, no message |
refusalAn open editor and refused choices
The choice takes the path of the checkbox toggle (SwRS-MDOKFSTUDIO-GFM-021): the same message type with the group's options, the same gates (SwRS-MDOKFSTUDIO-TRUST-005, SwRS-MDOKFSTUDIO-TRUST-065, SwRS-MDOKFSTUDIO-BLOCK-041), the same answer and the same refusal note.
| Input | Outcome |
|---|---|
| a click while a block or frontmatter editor is open | the guard runs on the press (mousedown, capture phase), before the editor's blur: the press is prevented, so the focus and the caret stay in the editor, nothing is committed and the editor stays open; the click that follows sends no message; the editor status reads 'Save or cancel this edit before choosing an option.' |
| a choice that reaches the host while a Markdown edit is open | refused with 'Save or cancel the open Markdown edit before choosing an option.' |
| a group whose lines no longer start with a radio marker at their columns | refused with 'The choice is no longer in the source. Refresh the preview.' |
| a group whose positions are not one run of consecutive radio items of one list in the current source (lines out of order, items of different indentation or list markers, or a blank line, another item, a heading, a thematic break or a code fence between two options) | refused with 'The choice is no longer in the source. Refresh the preview.', and no marker of another group changes |
| a file VS Code keeps read-only (files.readonlyInclude, or read-only in the session) | the apply resolves and changes nothing: refused with 'This file is read-only in VS Code.' |
| a radio group in the message that is not 2 to 256 distinct positions including the clicked one, or a choice with checked false (see SwRS-MDOKFSTUDIO-GFM-021) | refused with 'The checkbox request was not understood. Refresh the preview.' |
| any refusal | the previous selection and tab stop come back, and the reason shows next to the clicked option for about six seconds and as its tooltip |