Skip to content

fix(editor): stabilize code block caret alignment#591

Merged
murongg merged 1 commit into
v2from
fix/code-block-caret-alignment
Jul 27, 2026
Merged

fix(editor): stabilize code block caret alignment#591
murongg merged 1 commit into
v2from
fix/code-block-caret-alignment

Conversation

@murongg

@murongg murongg commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • keep code block language and copy controls aligned without overlapping code text
  • replace vertical margins and editable-line padding with measured 12px block spacing so repeated code blocks retain accurate pointer mapping
  • preserve the visual top and bottom inset, line-number gutter, borders, and rounded corners without changing code-row geometry
  • use a consistent monospace presentation with non-italic comments
  • require parsed ATX heading syntax before showing heading controls, preventing fenced-code comments from appearing as headings

Why

Tauri WebKit could map a click on one code row to the following row when hidden fence margins or vertical padding accumulated across consecutive code blocks. The spacing now participates in CodeMirror's height map instead of altering editable line boxes.

Validation

  • pnpm --filter @markra/app test — 127 files, 1447 tests passed
  • pnpm --filter @markra/editor test — 32 files, 353 tests passed
  • pnpm --filter @markra/app build passed
  • pnpm --filter @markra/app typecheck:test passed
  • pnpm --filter @markra/editor build passed
  • pnpm --filter @markra/editor typecheck:test passed
  • git diff --cached --check passed before commit
  • browser QA: verified consecutive code blocks line by line after a 300ms render delay; every caret stayed inside the clicked row
  • browser QA: verified 25 text-row clicks and direct interactions with frontmatter, tables, horizontal rules, math, raw HTML, images, and Mermaid without cumulative offset

Risk

  • limited to visual editor decorations and code block styling; no document-format or data migration changes
  • the main regression surface is wrapped code on narrow layouts, so the first row reserves inline space for the controls while all rows keep uniform vertical geometry

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markra-web Ready Ready Preview, Comment Jul 27, 2026 9:26am

@murongg
murongg merged commit b489762 into v2 Jul 27, 2026
21 checks passed
@murongg
murongg deleted the fix/code-block-caret-alignment branch July 27, 2026 09:28
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.

1 participant