[BUG] VS Code extension: nested fenced code blocks (longer outer fence, shorter inner fence) not recognized, breaking markdown rendering for rest of message

Status Open
Reported on v2.1.216
Maintainer reply None cached
Activity 1 comment · opened Jul 22, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

Description

When an assistant message contains a valid nested fenced code block — an outer fence using a _longer_ run of backticks (e.g. `` , 4 backticks) wrapping content that itself contains a _shorter_ fence (e.g. ` , 3 backticks) — the VS Code extension's chat panel markdown renderer does not respect CommonMark's backtick-run-length rule for fence closing. It treats the inner (shorter) closing fence as if it closed the _outer_ block, so everything after that point in the message is displayed as raw/literal code instead of rendered markdown.

Per CommonMark, a fenced code block's closing fence must consist of a run of the fence character at least as long as the opening run, with nothing but optional whitespace after it. A run shorter than the opening fence length is just ordinary content inside the still-open block. This is exactly why the "longer outer fence wraps a shorter inner fence" idiom exists (used to show markdown examples that themselves contain fenced code, e.g. in documentation-about-markdown).

What's Wrong? / What Should Happen?

See Expected / Actual below.

Environment

  • Claude Code VS Code extension, versions 2.1.216 and 2.1.217 (both observed installed; win32-x64)
  • Windows 11 Enterprise 10.0.26100
  • Reproduced in the extension's chat panel markdown rendering (did not check the terminal/TUI renderer)

Reproduction

  1. In a chat with Claude Code (VS Code extension), have the assistant emit a message containing a 4-backtick-fenced block wrapping a 3-backtick-fenced block, followed by more normal markdown, e.g.:

`````markdown

````markdown

graph LR
    A --> B

````

This text should render as bold, and this is a normal paragraph after the nested example.

`````

  1. Observe the rendered chat message.

Expected

Per CommonMark fence-closing rules, the whole 4-backtick block (including the inner 3-backtick fence) is a single code block, and everything after its true closing `` renders as normal markdown — bold text bold, paragraphs as paragraphs, etc.

Actual

The renderer treats the inner closing ` (3 backticks) as if it closed the outer block. Everything from that point onward in the message — including the outer block's real closing `` line and all the normal markdown that follows it — is displayed as raw/literal text (unrendered **bold**, no paragraph styling, etc.), rather than being parsed as markdown.

Claude Code Version

  • CLI (claude --version): 2.1.212 (Claude Code)
  • VS Code extension (bug is specific to this UI): 2.1.216 / 2.1.217

Is this a regression?

I don't know — haven't tested older extension versions.

Platform

Anthropic API (direct)

Operating System

Windows

Terminal/Shell

N/A — the bug is in the VS Code extension's chat panel webview rendering, not a terminal session. Closest template option: VS Code integrated terminal.

Claude Model

Not sure / Multiple models — this is a rendering bug independent of which model produced the message.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗