Sublime Forum

Add highlight for Cyrillic characters in code

#1

I was debugging a PHP error for 30 minutes that was caused by a Cyrillic character in one of the method names. I had assertЕquals and it should have been assertEquals. Easy error to spot, right. I kept getting this error:

Error: Call to undefined method EmailTest::assertЕquals()

Why? Because the letter E turned out to be Cyrillic and the actual method uses the Latin letter.

Proposal

It would be very awesome if Sublime can highlight invalid characters in red so you can know that something’s off. I can agree that errors like that occur rarely but when they do, they’re a pain in the A.

0 Likes

#2

As it is technically valid in a method name, and just doesn’t correspond to a defined method name, you should probably use a package like
https://packagecontrol.io/packages/Highlight%20Dodgy%20Chars
rather than expecting it to be done by the syntax highlighting

0 Likes

#3

Well, technically, yes. But how likely is it that you actually want to have a Cyrillic method name or variable? Any non-ASCII character for that matter. I haven’t seen such a thing anywhere.

I guess that can live in Sublime under an option if it’s easy to implement. Even though I’m a Bulgarian and I often work on sites with Cyrillic content, I have actual Cyrillic characters in my code extremely rarely. However, I often switch between languages and mistakes like the one today can happen sometimes.

What I’m saying is - if that setting existed, I would’ve had it turned on. Anyway, I’m gonna check the package you linked. Thanks!

1 Like