Skip to content

feat: continue Markdown prefixes with Vim o/O - #288

Open
homura144 wants to merge 2 commits into
esm7:masterfrom
homura144:codex/markdown-open-line
Open

feat: continue Markdown prefixes with Vim o/O#288
homura144 wants to merge 2 commits into
esm7:masterfrom
homura144:codex/markdown-open-line

Conversation

@homura144

Copy link
Copy Markdown

On Obsidian 1.13.7, pressing normal-mode o on - Item opens an unprefixed blank line, and quoted lists are inconsistent between o and O. This adds default Markdown-aware open-line actions: list, task, quote, and indentation prefixes are continued, with the caret placed after the new prefix in insert mode. No additional vimrc mappings or editing plugin are needed.

The actions are registered through the existing CodeMirrorAdapter.Vim path before the user's vimrc is loaded, so user mappings take precedence. They enter insert mode directly instead of sending a nested i command, preserving the open-line edit for . repetition and numeric counts. Visual-mode behavior is retained and read-only editors are not modified.

Opening below an empty list item removes its marker. Numbered items support . and ) delimiters and preserve zero padding; renumbering is limited to consecutive siblings with the same prefix and delimiter. Thematic breaks, fenced code, frontmatter, and display math are excluded from list continuation. The implementation is a line-prefix helper, not a full Markdown parser.

Validation:

  • npm test -- --run: 108 tests passed, including 46 new open-line tests.
  • npm run build: succeeded. The existing upstream TS2769 warnings for Vim event names in main.ts are still present; they were reproduced before this change.
  • node tests/build-smoke.cjs: confirms that the built plugin registers both default actions. Removing the registration makes this check fail; restoring it makes the check pass.
  • node tests/obsidian/run.cjs <vault>: 68 checks passed in desktop Obsidian 1.13.7, covering source/live preview modes, keyboard events, prefix/caret behavior, dot repetition, counts, undo, literal blocks, visual mode, and user mapping precedence.

The optional editor runner and its cleanup behavior are documented in tests/README.md.

Copilot AI lite review requested due to automatic review settings September 7, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The core behavior is well-scoped, integrated into the existing Vim registration flow, and is backed by substantial automated test coverage (with only a minor robustness nit in the optional Obsidian runner cleanup).

Pull request overview

This PR adds default Markdown-aware Vim open-line actions (o/O) so Obsidian’s CodeMirror editor continues list/task/blockquote/indentation prefixes when opening a new line, placing the caret after the prefix in insert mode and preserving . repeat and numeric counts.

Changes:

  • Add defineMarkdownOpenLine action registration early in the Vim command setup so user vimrc mappings can override it.
  • Implement Markdown prefix continuation (including numbered-list increment/renumber) with exclusions for literal blocks (fences/frontmatter/display math).
  • Add comprehensive unit tests plus optional Obsidian editor smoke checks and build-time mapping verification.
File summaries
File Description
utils/vimApi.ts Extends Vim action typing with Vim state + enterInsertMode hook needed by the new actions.
actions/openLine.ts Implements Markdown-aware o/O open-line behavior, including renumbering logic and literal-block exclusions.
main.ts Registers the new default open-line actions via the existing CodeMirrorAdapter.Vim registration path.
README.md Documents the new default o/O behavior and its Markdown-specific semantics.
tests/openLine.test.ts Adds unit coverage for prefix continuation, literal-block exclusions, and Vim registration behavior.
tests/README.md Documents how to run unit/build checks and the optional Obsidian editor runner.
tests/build-smoke.cjs Verifies the built plugin registers both open-line actions/mappings.
tests/obsidian/run.cjs Adds a CLI-driven runner to execute in-editor smoke checks against a running desktop Obsidian instance.
tests/obsidian/editor-smoke.js Implements the in-Obsidian checks for o/O, cursor placement, dot-repeat/counts, undo, literal blocks, and mapping precedence.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/obsidian/run.cjs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants