Skip to content

fix(editor): keep visual line clicks aligned - #701

Merged
murongg merged 1 commit into
v2from
fix/issue-700-cursor-position
Aug 29, 2026
Merged

fix(editor): keep visual line clicks aligned#701
murongg merged 1 commit into
v2from
fix/issue-700-cursor-position

Conversation

@murongg

@murongg murongg commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • move heading, paragraph, and blockquote rhythm from editable line padding/margins into measured CodeMirror block spacers
  • pass configurable paragraph spacing into the editor height model while preserving the existing visual spacing
  • keep ordinary inline input on a mapped fast path and rebuild spacing only for block-structural changes
  • add regression coverage for heading levels, paragraph preferences, blockquotes, blank-line edits, and syntax-scan performance

Why

CodeMirror maps pointer coordinates through a virtual height model. Vertical padding and margins applied directly to editable lines were not represented reliably in that model, so the rendered document became taller than CodeMirror expected and clicks landed on later lines. The drift accumulated in heading-rich documents on both desktop and web.

Validation

  • cd packages/editor && pnpm test && pnpm build && pnpm typecheck:test — 39 test files and 511 tests passed
  • cd packages/app && pnpm exec vitest run src/styles.test.ts src/components/CodeMirrorPaperSurface.test.tsx --environment jsdom --globals && pnpm build && pnpm typecheck:test — 2 test files and 105 tests passed
  • browser QA with the issue attachment confirmed clicks on 3.1.1, 3.1.2, and quoted paragraph rows keep the caret on the clicked visual line
  • git diff --check passed

Risk

  • the change adds measured editor-only decorations; Markdown content, saved files, clipboard output, and exports are unchanged
  • paragraph spacing remains configurable and is reconfigured without recreating the editor view

Screenshots

Not included because the intended visual spacing is unchanged; this fixes pointer-to-caret alignment.

Closes #700

Move heading, paragraph, and blockquote spacing into measured CodeMirror block widgets so virtual heights match the rendered layout.

Closes #700
@vercel

vercel Bot commented Aug 28, 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 Aug 28, 2026 10:44am

@murongg
murongg merged commit bf4a185 into v2 Aug 29, 2026
23 checks passed
@murongg
murongg deleted the fix/issue-700-cursor-position branch August 29, 2026 00:06
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.

[Bug]: 鼠标选中行数错误

1 participant