I ran into a similar problem in the Positron IDE.
I found the issue to be missing break after the chunk.
```{r}
code
```
Text
This would run into the problem but adding an additional break after the chunk fixed this.
```{r}
code
```
Text
Hope this helps someone else running into similar issues