feat: continue Markdown prefixes with Vim o/O - #288
Open
homura144 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
🟢 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
defineMarkdownOpenLineaction 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Obsidian 1.13.7, pressing normal-mode
oon- Itemopens an unprefixed blank line, and quoted lists are inconsistent betweenoandO. 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.Vimpath before the user's vimrc is loaded, so user mappings take precedence. They enter insert mode directly instead of sending a nestedicommand, 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 inmain.tsare 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.