Bug Report: Mermaid Diagram Code Block Content Misalignment in Chat

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Environment

  • Cursor Version: 1.7.28 (please update with your actual version)
  • OS: Linux 6.1.0-39-amd64
  • Date: October 3, 2025

Summary

When AI responses contain multiple Mermaid diagrams followed by code blocks, the code blocks display shifted/wrong content in Cursor’s chat markdown renderer. However, when the same chat is exported to a .md file, all content renders correctly in external markdown viewers.

Description

In Cursor’s real-time chat markdown renderer, when a response contains multiple sequential patterns of:

[Mermaid Diagram] → [Code Block] → [Mermaid Diagram] → [Code Block] → ...

The code blocks display incorrect content:

  • 1st code block: Shows the 1st mermaid diagram’s source code (should show Python/Bash code)
  • 2nd code block: Shows the 1st code block’s content (should show different code)
  • 3rd code block: Shows the 2nd mermaid diagram’s source code (should show code)
  • Pattern continues with consistent offset

Steps to Reproduce

  1. Ask AI to generate a response with multiple mermaid diagrams and code blocks
  2. Use this example content:
## Test 1
```mermaid
graph TD
    A["Node A"] --> B["Node B"]

This is test 1 code:

print("Test 1")
x = 1

Test 2

graph TD
    X["Node X"] --> Y["Node Y"]

This is test 2 code:

print("Test 2")
y = 2

Test 3 (no mermaid)

print("Test 3")
z = 3

Expected Behavior

  • Test 1 code block should display: print("Test 1")
  • Test 2 code block should display: print("Test 2")
  • Test 3 code block should display: print("Test 3")

Actual Behavior

  • Test 1 code block displays: graph TD A["Node A"] --> B["Node B"] (mermaid source)
  • Test 2 code block displays: print("Test 1") (previous code block)
  • Test 3 code block displays: graph TD X["Node X"] --> Y["Node Y"] (previous mermaid source)

Pattern: Each code block shows the content from 1-2 blocks earlier, creating a systematic offset.

Critical Evidence

The exported markdown file is completely correct!

When exporting the chat conversation to .md file and opening in external markdown renderers (Typora, VS Code, Mark Text, etc.), all content displays correctly without any offset. This proves:

  1. :white_check_mark: AI-generated markdown source is correct
  2. :cross_mark: Cursor’s real-time chat markdown renderer has a content buffering/caching bug
  3. :white_check_mark: Mermaid diagrams themselves render correctly
  4. :cross_mark: Only the subsequent code blocks show wrong content

Screenshots / Screen Recordings

Operating System

Linux

Current Cursor Version (Menu → About Cursor → Copy)

  • Cursor Version: 1.7.28 (please update with your actual version)
  • OS: Linux 6.1.0-39-amd64
  • Date: October 3, 2025

Does this stop you from using Cursor

Yes - Cursor is unusable

Thanks for sharing the report. I’ve shared the feedback with the team.

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.