[TxMt] Serious bug with Python syntax highlighting

Nicolas Weber nicolasweber at gmx.de
Tue Feb 6 11:16:14 UTC 2007


Hi,

I've stumbled on a problem with TextMate's python handling which goes  
into an infinite loop (or a really long computation) during certain  
circumstances. When this happens, TextMate doesn't react to any input  
anymore, which causes dataloss of everything typed after the last save.

I have the following function (<> only shows the position of the  
caret and is no text) in a python file:

def c(docstring, baseindent=0):
   #from http://www.python.org/dev/peps/pep-0257/
   lines = docstring.splitlines()
   # Determine minimum indentation (first line doesn't count):
   indent = sys.maxint
   for line in lines[1:]:
     stripped = line.lstrip()
     if stripped:
       indent = min(indent, len(line) - len(stripped))
   # Remove indentation (first line is special):
   trimmed = [<>lines[0].strip()]
   if indent < sys.maxint:
     indent -= baseindent
     for line in lines[1:]:
       trimmed.append(line[indent:].rstrip())
   # Return a single string:
   return '\n'.join(trimmed)

Now I type ]<enter> and watch TextMate die. It'd be cool if this  
could be fixed.

To reproduce the problem:
1. Open TextMate
2. Paste the above function into TextMate, put your caret where <> is  
(and remove <> from the text)
3. Go into python mode (shift-ctrl-opt-p 4)
4. enter ]<cr>


Bye,
Nico



More information about the textmate mailing list