posit-dev / positron

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

R (I think R specific): Syntax highlighting or diagnostics problems around underscores #994

Closed juliasilge closed 1 year ago

juliasilge commented 1 year ago

The syntax highlighting seems to be having some problems around underscores. Notice vetiver_write_plumber, rlang::is_installed(), and similar:

Screenshot 2023-08-09 at 10 25 00 AM

This problem continues throughout the file, not only in roxygen comments. It's quite extremely confusing by the time I get to the bottom of the file:

Screenshot 2023-08-09 at 10 28 41 AM

juliasilge commented 1 year ago

Are these "unmatched closing bracket 'comma'" problems related to the underscore problems, hopefully?

Screenshot 2023-08-09 at 11 13 17 AM

kevinushey commented 1 year ago

Can you please share a minimal reproducible example (with the textual content that reproduces the issue)?

We probably need something smarter for the Markdown highlight rules here:

https://github.com/rstudio/positron/blob/4af4dc14da9f31d9380d8567e9aa81d9df46ab52/extensions/positron-r/syntaxes/r.tmGrammar.src.json#L296-L324

Compare with e.g. the RStudio rules, which try to be a fair bit smarter:

https://github.com/rstudio/rstudio/blob/f36933632eddcfaade37c5096cded881919e0d6a/src/gwt/acesupport/acemode/r_highlight_rules.js#L91-L114

It's also possible that we could simplify things by allowing the comment "tokenizer" to consume whole words containing underscores, though.

juliasilge commented 1 year ago

I don't know that we need another example but this file really demonstrates the problem 😆

Screenshot 2023-08-09 at 4 24 20 PM