I've just started using TextMate for perl editing and I noticed today when I opened up a file that this line of code confusing the syntax coloring...
if ($link eq '' || $user eq '' || $user =~ / / || $link =~ / /) { ... }
TextMate saw a string starting at the first ~ and never stopping.
I looked through the bundle and I found what seemed to be the problem here...
{ name = 'string.regexp.find.perl'; match = '(?<!\)((~\s*)?/)(\S.*?)(?<!\)(\{2})*(/)'; captures = { 1 = { name = 'punctuation.definition.string.perl'; }; 5 = { name = 'punctuation.definition.string.perl'; }; }; },
The \S there is matching any non-whitespace character so it doesn't like the space character being used between the //. I changed that match line to this and it seems to have fixed it for me...
match = '(?<!\)((~\s*)?/)([\S| ].*?)(?<!\)(\{2})*(/)';
Is there any reason that's not a wise change to make?
Thanks for any info, Dallas
On 13/10/2007, at 02:46, Dallas Kashuba wrote:
[...] The \S there is matching any non-whitespace character so it doesn't like the space character being used between the //. I changed that match line to this and it seems to have fixed it for me... [...] Is there any reason that's not a wise change to make?
The reason for the non-whitespace character required directly after / is to avoid false positives like:
$var = $foo / 4 + $bar / 2;
I think your change will now flag ‘/ 4 + $bar /’ as a regexp.