question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntax highlighting fails when there's a vector argument

See original GitHub issue

I came here by following the link in [...]/code/resources/app/extensions/r/syntaxes/r.tmLanguage.json so I hope I’m in the right place.

Describe the bug

A clear and concise description of what the bug is.

The following code breaks the syntax highlighting; everything after the last quote is considered part of an (unfinished) string

fun <- function(a, c = c("a", "()"), d) {
    function body, not a quoted string
}

syntax

It seems to view the close bracket within the quoted string as the end of the function args.

To Reproduce Steps to reproduce the behavior:

  1. Open an R file
  2. Copy or type that code
  3. Observe the results

Do you want to fix by self? (We hope your help!)

I have tried to, but I’m not familiar with textmate grammars… so… maybe? I gather I’ve got to mess with function-parameters so that it no longer views the close bracket as the end of the function args, probably by allowing arguments to have default values that are the evaluation of function calls

(If yes,) what kind of help do you want? (e.g. Which file should I fix, Survey (related documents)

Expected behavior Pretty clear I think

Screenshots Above

Environment (please complete the following information):

  • OS: Linux
  • VSCode Version: [e.g. 1.58.2]
  • not important
  • also unimportant, but I’m testing with the current language definition in this repo

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
ElianHughcommented, Aug 13, 2021

The issue is definitely with the function declarations section, replacing the function-declarations match pattern with the textmate repo’s pattern fixes the issue.

1reaction
ElianHughcommented, Jul 23, 2021

(to state the obvious) it looks like brackets are still being parsed as punctuation when quoted and in the presence of function. this leads me to think it’s an issue with the function-declarations definition

image image image

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code highlighting wrong errors - c++ - Stack Overflow
I was simply declaring an array of size 'n'. The bigger problem is that the code is running perfectly but VS code shows...
Read more >
A case against syntax highlighting - Linus Åkesson
In this post, I will argue that syntax highlighting, ... There are two cases in which syntax highlighting can actually contribute something.
Read more >
Consider using a better maintained shellscript grammar #77675
But it breaks highlight just the next line in vscode. The broken behavior is triggered by the (( in the regex. GitHub's syntax...
Read more >
Syntax Error - an overview | ScienceDirect Topics
Confirm that the Code Analyzer highlights the error. Fix the error and confirm that the highlighting disappears. The following code contains a syntax...
Read more >
Debugging R code
Most code editors (such as RStudio) offer syntax highlighting and automatic indentation. ... Error in sum(x, "a"): invalid 'type' (character) of argument.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found