Very easy to reproduce in deepseek R1
It happens when the resulting markdown contains a code block. The code block kind of make the composer switch form âfile contentâ to âoutput contentâ. The result is that the target markdown file only contains the changes prior to the code block and the composer output contains the rest.
Hey, does this happen with any model specifically, or all of them?
I was able to reproduce it with this prompt (test.md being an empty file):
âIn test.md file, give me an explanation in markdown format for a command line to commit to git with a usage example in a powershell code block.â
As you can see in the screenshot, after the title â## Basic syntaxâ, composer outputs a bash code block that gets âoutâ of the test.md file to land in the composer output with the rest of the changes.
It is the same behaviour on claude sonnet, gtp-4o and cursor-small
Hey, we have this case fixed internally, and will hopefully get this out to you in 0.46! No ETA right now yet, still testing
Also experiencing this bug whenever models generate code blocks inside markdown.
Looking forward to the fix in 0.46.
finally!! thank u for your great efforts
Still happening with me. I am using Cursor 0.45.14 with claude-3.7-sonnet
Cursor should instruct the LLM to use XML to delimit files
Edit
Have tried 0.46.11 and the following solution is not needed anymore . It just works, without any rules!
I can easily fix this problem by adding the following to the âRules for AIâ setting:
While generating Markdown code, if the Markdown code contains code blocks, remember to enclose the outermost Markdown code block with at least 4 backticks, instead of only 3.
You can see the rendering was problematic before I added the rule:
But the problem is fixed after adding the rule:
The reason is that the Markdown spec (CommonMark) allows more than 3 backticks and requires that the closing code fence must be at least as long as the opening fence.
This way, the model can safely use the backticks in Markdown. Youâll get the code blocks as expected in the generated Markdown files/snippets without turning them into plain text.
If it doesnât work, maybe you can try a more detailed prompt. Hope this helps.
Cursor version: 0.45.14.
Model: Claude 3.5 Sonnet