Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

"/[]/" breaks syntax highlighting #244

Open
roblourens opened this issue Jul 27, 2017 · 5 comments
Open

"/[]/" breaks syntax highlighting #244

roblourens opened this issue Jul 27, 2017 · 5 comments
Labels

Comments

@roblourens
Copy link
Contributor

Can repro in VS Code and Atom.

string.regexp.character-class.php never ends.

image

image

@hultberg
Copy link

Can reproduce in atom 1.19.

screen shot 2017-07-27 at 20 20 01

@50Wliu
Copy link
Contributor

50Wliu commented Jul 27, 2017

I mean, this is technically correct. You can't have an empty character class. []] is interpreted as "match any of the following: ]". Tempted to close as wontfix.

http://php.net/manual/en/regexp.reference.character-classes.php (emphasis mine)

An opening square bracket introduces a character class, terminated by a closing square bracket. A closing square bracket on its own is not special.

@50Wliu 50Wliu added the wontfix label Jul 27, 2017
@roblourens
Copy link
Contributor Author

If the string is necessarily a regex, I guess that's the right call. But it could just be a string that happens to have those 4 characters, right? This would be valid PHP, and also break the coloring of the whole file:

<?php

$x = "/[]/";
echo $x;

// ...

Could the pattern terminate at line end?

@50Wliu
Copy link
Contributor

50Wliu commented Jul 27, 2017

Hmm...I was under the impression that "/.../" would always be a regex. I'll take a look to see if there's a simple fix, but generally the regexes for the regex are quite unforgiving :(.

@Ingramz
Copy link
Contributor

Ingramz commented Jul 27, 2017

@50Wliu to add to that, regex delimiters are not just limited to /.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants