Changeset 1177

Show
Ignore:
Timestamp:
03/16/08 15:02:00 (8 months ago)
Author:
rob
Message:

Fixed #403: Changed PythonAutoindent?.findIndent to ignore comment lines that start in column zero
* changed the input to the PyParse? indenter so that it doesn't even look at comments that start in column zero.
* also was able to remove a hackish way to convert lines to \n only (since PyParse? is hardcoded to \n line ending characters and barfs on mac or windows style end of lines)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/plugins/python_mode.py

    r1170 r1177  
    9797            rawtext = stc.GetTextRange(start, end) 
    9898             
    99             # FIXME: for now, rather than changing PyParse, I'm converting 
    100             # everything to newlines because PyParse is hardcoded for newlines 
    101             # only 
    102             if stc.getLinesep() == "\r\n": 
    103                 #dprint("Converting windows!") 
    104                 rawtext = rawtext.replace("\r\n", "\n") 
    105             elif stc.getLinesep() == "\r": 
    106                 #dprint("Converting old mac!") 
    107                 rawtext = rawtext.replace("\r", "\n") 
    108             y.set_str(rawtext+"\n") 
     99            # Handle two issues with this loop.  1: Remove comments that start 
     100            # at column zero so they don't affect the indenting.  2: PyParse 
     101            # is hardcoded for "\n" style newlines only, so by splitting the 
     102            # lines here we can change whatever the newlines are into "\n" 
     103            # characters. 
     104            lines = [] 
     105            for line in rawtext.splitlines(): 
     106                if len(line) > 0: 
     107                    if line[0] != '#': 
     108                        lines.append(line) 
     109            lines.append('') # include a blank line at the end 
     110            rawtext = "\n".join(lines) 
     111            y.set_str(rawtext) 
    109112             
    110113            bod = y.find_good_parse_start(build_char_in_string_func(stc, start))