Skip to content

[codex] Improve code block insertion - #94

Open
bendsp wants to merge 1 commit into
codex/editor-quality-passfrom
codex/feature-code-block-empty-insert
Open

[codex] Improve code block insertion#94
bendsp wants to merge 1 commit into
codex/editor-quality-passfrom
codex/feature-code-block-empty-insert

Conversation

@bendsp

@bendsp bendsp commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • make the fenced code block command insert an editable empty block on blank lines
  • preserve indentation for empty fenced block snippets
  • place the cursor inside the new fence and cover the behavior with unit tests

Validation

  • pnpm lint
  • pnpm typecheck
  • pnpm test:unit

Copilot AI review requested due to automatic review settings May 9, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves the CodeMirror “fenced code block” toggle command so that when invoked on a blank/whitespace-only line with an empty selection, it inserts an empty fenced code block and places the cursor inside it (while preserving the line’s indentation).

Changes:

  • Add a special-case path in toggleFencedCodeBlockCommand for empty selections on blank lines to insert an editable empty fenced block and move the cursor into it.
  • Preserve leading indentation when inserting an empty fenced block snippet.
  • Add unit tests covering empty-block insertion, cursor placement, and indentation preservation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/renderer/editor/codemirror/commands.ts Adds blank-line empty-selection handling to insert an indented empty fenced block and position the cursor inside it.
tests/controllerShortcuts.test.ts Adds unit tests validating the new empty fenced block insertion behavior and cursor position.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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