Behaviour SwRS-MDOKFSTUDIO-BLOCK-061
Tab, Shift+Tab and Enter indent and continue lists, quotes and fences
When a writer presses Tab, Shift+Tab or Enter in the text box of a block editor, the page SHALL indent or outdent every line touched by the selection, or continue the list marker, quote prefix or indentation of the current line, and leave the key to the text box when no rule applies.
Step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-008: from “A block editor is open on a list” to “The next item starts with its marker”.
Scenarios 7
The situations the tests check; open one to read it.
nominalTab indents the lines touched by the selection
| Input | Outcome |
|---|---|
| Selection over the list lines `- a` and `- b` | Each gains two spaces (` - a`, ` - b`); a numbered `1. a` gains three, `10. a` four |
| Selection over two prose lines | Each gains four spaces; a quote prefix stays in front; the editor stays open |
| Collapsed caret on the prose line `some prose` after `some` | The text becomes `some prose` with the caret after the four spaces |
| Collapsed caret at the end of the list line `- a` | The whole line is indented by the marker width instead: ` - a` |
nominalShift+Tab outdents the touched lines
| Input | Outcome |
|---|---|
| ` - a` with the caret at its end | The line becomes ` - a` |
| ` - a` | The line becomes `- a` |
| ` plain` | The line becomes `plain` |
| `- a` (nothing to remove) | The text is unchanged, the key is still consumed and the editor stays open |
Up to one indentation unit, or one tab, is removed from the start of every touched line.
nominalEnter continues the list marker
| Input | Outcome |
|---|---|
| `- a`, `* a` or `+ a` with the caret at the end | The next line starts with the same bullet and a space |
| `1. a` | The next line starts with `2. ` |
| `9) a` | The next line starts with `10) ` |
| An indented item | The next line keeps the indentation |
| `- [x] done` | The next item starts with `- [ ] ` (box reset) |
| `- ( ) a` or `- (x) a` (an option item) | The next item starts with `- ( ) ` (marker reset); a numbered `1. ( ) a` gives `2. ( ) ` |
| `- ab` with the caret between a and b | The line splits into `- a` and `- b` |
nominalEnter continues a quote prefix or the indentation
| Input | Outcome |
|---|---|
| `> quote` with the caret at its end | The next line starts with `> ` |
| ` code` with the caret at its end | The next line starts with four spaces |
| `plain` without indentation | The page leaves the key to the text box |
The list marker, the quote prefix and the indentation are the only constructs that Enter continues.
boundaryEnter on an empty list item or quote line
| Input | Outcome |
|---|---|
| The lines `a`, ` - ` and `b` with the caret on the empty item | The item line becomes empty and the caret sits on it |
| The line `> ` with the caret at its end | The line becomes empty |
| The line `- ( ) ` (an option item with no text) with the caret at its end | The line becomes empty, which ends the option list |
boundaryEnter inside a fenced code block
| Input | Outcome |
|---|---|
| `` ```\n x `` with the caret after the x, inside the fence | The next line starts with two spaces |
| `` ```\n- a `` with the caret at the end of the last line | The key is left to the text box; after the closing fence a list is continued again |
Only the indentation of the current line is continued while an odd number of fence lines lies above the caret.
refusalThe key stays native
| Input | Outcome |
|---|---|
| Tab with Ctrl, Cmd or Alt held, or during an IME composition | The page does not handle the key; Ctrl+Tab still reaches VS Code |
| Shift+Enter at the end of a list item | The text box inserts a plain line break without a marker |
| Enter with Alt, Ctrl or Cmd, with a non-collapsed selection or during an IME composition | The page leaves the key to the text box |
| Enter with the caret before or inside the marker, as in `|- a`, `-| a` or `- (| ) a` | The page does not continue the list |