0

I'm developing a VS Code extension to support a new language, and for some syntax highlight I want to match any text between = object and (.

I tried the following Regex:

{
    "name": "entity.name.class",
    "match": "(?<==\\s*object).*?(?=\\()"
},

But when I add this to my grammar file it breaks all the other rules that were working, everything turns white again.

That Regex (?<==\s*object).*?(?=\()/g works on https://regexr.com/ with the following text:

!var = object REAL()
!var = object BORE(!bore)
!var =object REAL  ()
!var =object BORE  (!bore)

VS Code doesn't give me any exception or hint why this Regex is not working, does anyone have a clue on why the Regex is not working in VS Code?

Gama11
  • 31,714
  • 9
  • 78
  • 100
rbasniak
  • 4,484
  • 11
  • 51
  • 100

1 Answers1

0

You mention that adding your new pattern causes your test file to lose all syntax highlighting. This leads me to believe that you have a syntax issue within the actual grammar that's preventing any syntax pattern application. Your regular expression, while not optimal, seems to be syntactically correct, so I doubt that's the cause of your problem. For future reference, VS Code only applies syntax pattern matching one line at a time. This means that if your regex was incorrect, only the lines that match the pattern would lack the syntax highlighting, rather than the whole document.

Hopefully this answer isn't too late for your problem.