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
RStudio Edition : Desktop
RStudio Version : Version 2023.12.1+402 (2023.12.1+402)
OS Version : 12.7.3
R Version : 4.3.2
Steps to reproduce the problem
I cannot attach a .Rnw file to the issue, but I have pasted in the complete text of the file saved as .Rnw that shows the problem.
\documentclass{article}
\begin{document}
<<>>=
my_data <- 1:5
@
The value of my data is \Sexpr{my_data}.
for example, you can see how the word "for" at the beginning of this sentence is not color-coded.
However, now we use \Sexpr{my_data[2]}.
for example, you can see how the word "for" at the beginning of this sentence is coded as if it were code (same with "if").
And if we put a quote mark here' now everything after it is seen as code quote'.
This appears to be a bug, and if there is an ending single quote the end of document is not read when knitted directly by the IDE. Although knitting the document via code like
knitr::knit('test.Rnw')
does work.
'
\end{document}
Describe the problem in detail
This problem with the RStudio IDE involves working with .Rnw or Sweave files and a specific use of \Sexpr{}, which is the tag for inline code. I have found that a use of \Sexpr{} that includes square brackets, such as \Sexpr{my_data[2]}, somehow activates the IDE to turn on code highlighting for all text after the square brackets. The file still does compile but the code highlighting is broken.
In the following screenshot you can see how on line 15 the word "for" is coded as text (while on line 11 it is not), and other parts of the document after apostrophes are also "commented out" in green text (including the \end{document} tag on line 25:
Describe the behavior you expected
The expected behavior is that code highlighting should never be turned on.
System details
Steps to reproduce the problem
I cannot attach a .Rnw file to the issue, but I have pasted in the complete text of the file saved as .Rnw that shows the problem.
Describe the problem in detail
This problem with the RStudio IDE involves working with .Rnw or Sweave files and a specific use of
\Sexpr{}
, which is the tag for inline code. I have found that a use of\Sexpr{}
that includes square brackets, such as\Sexpr{my_data[2]}
, somehow activates the IDE to turn on code highlighting for all text after the square brackets. The file still does compile but the code highlighting is broken.In the following screenshot you can see how on line 15 the word "for" is coded as text (while on line 11 it is not), and other parts of the document after apostrophes are also "commented out" in green text (including the \end{document} tag on line 25:
Describe the behavior you expected
The expected behavior is that code highlighting should never be turned on.
The text was updated successfully, but these errors were encountered: