posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.58k stars 79 forks source link

`@examples` section messes up highlighting in roxygen2 blocks further down the page #1360

Open hadley opened 1 year ago

hadley commented 1 year ago

Positron Version:

Steps to reproduce the issue:

Screenshot 2023-09-21 at 16 26 17

cf https://github.com/r-lib/devtools/blob/main/R/package.R#L88

What did you expect to happen?

Looks like something further up the page leaves the parser in the wrong state.

Were there any error messages in the output or Developer Tools console?

kevinushey commented 1 year ago

Looks like this is caused by the #' @examples block above. A smaller reprex:

#' @examples
#' print(1 + 1)
NULL

#' Uh oh
Screenshot 2023-09-22 at 1 04 18 PM

Note that the text within the Roxygen documentation is being highlighted as though it were R code still.

Screenshot 2023-09-22 at 1 05 03 PM
kevinushey commented 1 year ago

Here's the offending code:

https://github.com/posit-dev/positron/blob/8611f6e00feff9eaf8dc90a1606285faa3e3c982/extensions/positron-r/syntaxes/r.tmGrammar.src.json#L427-L436

We need to improve how the "end" of an roxygen example code chunk ends.

mine-cetinkaya-rundel commented 1 year ago

Another instance of wrong highlighting in comments, not in roxygen comments but for comments followed by 4+ dashes:

Screenshot 2023-09-25 at 9 47 11 PM
kevinushey commented 1 year ago

That was intentional; the goal there is to help comment-style section titles stand out. Do you prefer the "plain" comment styling?

mine-cetinkaya-rundel commented 1 year ago

@kevinushey Having them stand out could be nice, but the color matching the default/code color doesn't make them stand out to me. I'd prefer either plain comment styling or using a different color (like a lighter green or something here) to have them stand out. Turning that text to black seems like it's not being interpreted as a comment.

DavisVaughan commented 1 month ago

Just hit this again for the docs of between() in dplyr

https://github.com/user-attachments/assets/70fd5721-44c0-4922-971f-0d6394d7d6db