Ticket #403 (closed enhancement: fixed)

Opened 6 months ago

Last modified 6 months ago

Ignore comments when reindenting in python mode

Reported by: rob Owned by: rob
Priority: minor Milestone: 0.7.3
Component: application Keywords:
Cc:

Description

Chris Barker noted the following:

    for i in list:
#        a commented line
This line indents wrong!

I wrote the following to the mailing list: I've noticed that problem. Interestingly, (x)emacs has the same issue with a single comment char at column zero. However, in emacsland, if the comment starts with two comment chars, that comment is placed outside the normal flow of indenting:

    for i in list:
##       a commented line
        print i

Emacs indents the print correctly, but a single comment char causes emacs to treat that line as valid and so indents the print to column zero. Also, I'm not sure that comments should be ignored completely, for instance:

    for i in list:
        print i
    # first comment -- at the level of the for statement
    # second comment

I'd like the second comment to be indented to the same level as the first comment when I press the tab key, but if the indenting ignores all comments it would be indented to the print statement.

Maybe just ignore comments that start at column zero? Or, maybe implement the emacs thing (double comment chars)? I think the emacs thing might be better. Double comments to indicate block comments that are outside the flow of indenting.

Attachments

Change History

Changed 6 months ago by rob

  • status changed from new to closed
  • resolution set to fixed

(In [1177]) 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)

Add/Change #403 (Ignore comments when reindenting in python mode)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.