Home Download Buy Blog Forum Support

BUG: Python syntax highlight fail

BUG: Python syntax highlight fail

Postby est on Thu Aug 26, 2010 8:30 am

SL will fail to syntax highlight the rest of python code when encountered this

Code: Select all
m = re.compile(r'[^[]+\[(\d+/[A-Za-z]+/\d+):[^\d]*').match(line)


perhaps [^ is treated as ANSI escape char?
Attachments
1.png
1.png (117.37 KiB) Viewed 707 times
est
 
Posts: 6
Joined: Tue Aug 24, 2010 9:15 am

Re: BUG: Python syntax highlight fail

Postby Chortos-2 on Mon Sep 13, 2010 9:34 pm

There is an unpaired opening bracket in that regular expression, and the syntax highlighter is waiting for the pair to be closed. Are you sure the very first bracket in the regexp is intended?

Edit: oh, I get it now. I did not notice it at first, but [^[] is a well-formed character class.

This issue should really be fixed upstream in TextMate, but meanwhile here is a patch to %APPDATA%\Sublime Text\Packages\Python\Regular Expressions (Python).tmLanguage:
Code: Select all
--- original/Regular Expressions (Python).tmLanguage   Thu Oct 15 20:57:32 2009
+++ modified/Regular Expressions (Python).tmLanguage   Tue Sep 14 01:07:19 2010
@@ -235,7 +235,7 @@
            </dict>
            <dict>
               <key>begin</key>
-               <string>(\[)(\^)?</string>
+               <string>(\[)(\^)?\]?</string>
               <key>beginCaptures</key>
               <dict>
                  <key>1</key>
@@ -264,8 +264,16 @@
               <key>patterns</key>
               <array>
                  <dict>
-                     <key>include</key>
-                     <string>#character-class</string>
+                     <key>match</key>
+                     <string>\\[wWsSdDhH]</string>
+                     <key>name</key>
+                     <string>constant.character.character-class.regexp</string>
+                  </dict>
+                  <dict>
+                     <key>match</key>
+                     <string>\\.</string>
+                     <key>name</key>
+                     <string>constant.character.escape.backslash.regexp</string>
                  </dict>
                  <dict>
                     <key>captures</key>
Last edited by Chortos-2 on Sat Sep 18, 2010 8:48 pm, edited 1 time in total.
Chortos-2
 
Posts: 16
Joined: Thu May 27, 2010 5:13 pm
Location: Riga, Latvia, the EU, Europe, Eurasia, the Earth, the Solar System, the Milky Way, the Universe

Re: BUG: Python syntax highlight fail

Postby est on Sat Sep 18, 2010 4:12 am

Thanks for the patch, Chortos-2

I didn't expect it's a Textmate bug.
est
 
Posts: 6
Joined: Tue Aug 24, 2010 9:15 am


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 19 guests