Skip to content

Saving after an unrelated edit corrupts fenced code inside blockquotes #3

Closed

Description

@BinaryOutlook

Editing an ordinary paragraph can corrupt an otherwise untouched fenced code block inside a blockquote when the document is saved. Fences disappear, code lines concatenate, and code-toolbar text enters the saved Markdown.

Validated on main at d50e1fd1ad080fadf416098a582fe0a277d1ad43 (package version 0.2.1), 2026-09-16 UTC. Environment: macOS 26.5.2, arm64.

Reproduction

Open this synthetic document in visual mode using the Things theme:

> ```
> alpha
> beta
> ```

After
  1. Confirm that the quoted code block initially contains two lines.
  2. Append updated to the After paragraph. Do not edit the code block.
  3. Save and inspect the resulting Markdown.
  4. Reload that saved Markdown in preview.

Expected: only the final paragraph changes; the quoted fence, its language, and both code lines remain intact.

Observed saved content with English UI labels:

> ⤢plaintextCopy
> alphabeta

After updated

Reloading this output produces no code block. The same failure occurs with a javascript fence. Saving the untouched original before making any edit preserves its source; the corruption occurs when a visual edit requires DOM serialization. The code Copy control separately preserves the two original lines.

Cause and suggested scope

mdProcessBlockquote lacks a fenced-pre branch. It walks the code header as content and handles the block's code element through the inline path. Add block-aware serialization that reuses the existing code-block serializer, excludes editor controls, and prefixes every resulting line with the quote marker.

Regression coverage should include unrelated paragraph edits, labelled/unlabelled quoted code, internal and trailing blank lines, saving/reopening, source switching, copying, and quoted math/Mermaid interactions. This is a source-integrity bug independent of indented-fence recognition.

Validation boundary

Reproduced through real keyboard input and save handling in Chromium with the production webview HTML/CSS/JavaScript. Captured the outgoing save payload at a mocked VS Code API boundary and rendered that payload again. Repeated with vendor JavaScript enabled and disabled; both corrupted the output without JavaScript exceptions. An installed-extension filesystem save was not exercised. All examples are synthetic.

Activity

  1. added
    bug
    on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions