Skip to content

feat: #2052 indent and outdent selected lines and list items - #5905

Merged
Jocs merged 3 commits into
developfrom
feat/2052-selection-indentation
Oct 27, 2026
Merged

Jocs merged 3 commits into
developfrom
feat/2052-selection-indentation

Conversation

@Jocs

@Jocs Jocs commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Closes #2052
Closes #2371
Closes #3205

Summary

Selecting several list items and pressing Tab or Shift+Tab previously did nothing. Code selections also lacked consistent multiline outdent and ignored the configured indentation width. This PR applies indentation to the selected lines/items, restores both selection endpoints, and records each key press as one undo step.

  • Move contiguous sibling list items together, including task items. Preserve ordered start numbers, remaining tails, and endpoints in cloned but unselected items.
  • Indent/outdent code lines using the existing Tab input preference. Shift+Tab can continue to column zero regardless of the previous line's indentation. Selected code and Shift+Tab skip HTML completion.
  • Convert indented paragraphs immediately into CommonMark indented code blocks when they reach four columns. Merge consecutive indented paragraphs with their intervening blank lines; consume structural indentation while retaining code payload tabs and additional spaces.
  • Keep indented continuation lines in their paragraph when they cannot start a code block. Split a code prefix from an unindented tail, recognizing newly exposed block syntax such as a non-interrupting ordered-list marker. Support paragraphs within the same quote container.
  • Exclude the final line/item when the selection ends at its beginning. Keep forward/backward selections and undo/redo valid across block conversion. Single-line text selections retain replacement behavior. Unsupported mixed-block selections stay unchanged.

Implementation and review

block/listOperations.ts owns the structural rules shared by caret and selection indentation: item kinds, sublist reuse, looseness, tail ownership, numbering, and cloned leaf mappings. ParagraphContent passes one item; the editor coordinates selected ranges. Caret-only exit from a nested list to a paragraph and table navigation remain unchanged.

block/paragraphIndentation.ts reconciles edited paragraph siblings using the existing Markdown lexer for code boundaries and the existing parser for a newly exposed paragraph tail. Its temporary source spans map the selection after structural whitespace is consumed; no source spans or new fields are persisted in document state. Both paragraph input and cross-paragraph selection handling use this conversion.

Validation

Related scope

Real Tab input and code payload preservation were implemented by #5891, which also resolves #2114. This PR adds no preference keys or document state fields and does not change parser/serializer implementations. Exact source-whitespace preservation remains tracked by #2189.

Additional Ctrl+[/Ctrl+] command shortcuts (#2994) and Python-aware Enter indentation (#2427) remain separate requests.

@Jocs
Jocs force-pushed the feat/2052-selection-indentation branch from 204a144 to e761d91 Compare October 27, 2026 05:39
@Jocs
Jocs merged commit 6b192ba into develop Oct 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant