You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bad highlighting of nested code chunks in R Markdown documents #1500
vscode-R incorrectly highlights nested code chunks in R Markdown documents, stopping after the first closing chunk. E.g.:
````{verbatim}
```{r}
foo <- 1
```
````
produces:
I'd expect to have the outermost chunk (verbatim here) fully highlighted. Note that the quarto extension highlights nested code chunks properly. That would be great to get this work for .Rmd files too though.
The chunk scanner treated every line of three or more backticks as the end of the open chunk. It did not record the length of the opening fence, so a shorter inner fence matched the same end pattern as the outer one.
The scanner now stores the opening fence length and closes the chunk only when a later fence is at least that long. A shorter fence stays inside the outer chunk as content.
Activity
ThomasSoeiro commentedon Oct 23, 2026
@arnaudgallou can you please provide a screenshot of your expected result? (and also in RStudio for completeness)
mvanhorn commentedon Nov 14, 2026
The chunk scanner treated every line of three or more backticks as the end of the open chunk. It did not record the length of the opening fence, so a shorter inner fence matched the same end pattern as the outer one.
The scanner now stores the opening fence length and closes the chunk only when a later fence is at least that long. A shorter fence stays inside the outer chunk as content.
#1947
fix: highlight nested R Markdown chunks through the outer fence (REdi…