Bogus whitespace left in docstring after wrapping

Bug #1178455 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

r1225

def foo():
    """Line one of a comment.

    A paragraph of comments.
    These should get wrapped correctly.
    They do, but whooboy!

    Last line of comment.
    """

Put point somewhere in the middle paragraph and hit M-q (fill-paragraph).

The paragraph gets properly wrapped, but the blank line before it and after it get additional 4 bogus spaces at the beginning of their lines.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.1.2
importance: Undecided → Medium
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Barry,

the docstring get's indented as such. I.e. it get's the indentation a C-j from inside would make.
Do you think that's wrong? Is there a case where it disturbs?

Cheers,

Andreas

Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 1178455] Re: Bogus whitespace left in docstring after wrapping

On May 13, 2013, at 05:28 PM, Andreas Roehler wrote:

>the docstring get's indented as such. I.e. it get's the indentation a C-j
>from inside would make. Do you think that's wrong? Is there a case where it
>disturbs?

Yes. Take the following example:

def foo():
    """This is the foo method.

    The foo method does stuff.
    It does other stuff too.
    Oh, but it does not do some other stuff.

    Use the foo method with caution.
    """

In this case, you'll notice that the blank lines surrounding the middle
paragraph are indeed blank. No indentation is present.

Now use M-q to re-fill the middle paragraph. The separating lines suddenly
grow 4 leading spaces making them non-empty. Normally, you can't see the
spaces unless you turn on global-whitespace-mode or similar, but that makes
the problem worse.

Imagine you have a unit test that requires those lines to be really blank,
i.e. empty. M-q would break those tests.

Thus, it is critical that filling a paragraph not change the indentation of
the surrounding blank lines.

Changed in python-mode:
status: New → In Progress
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Thanks for the explanation. Fix follows.

Andreas

Changed in python-mode:
status: In Progress → Fix Committed
Revision history for this message
Barry Warsaw (barry) wrote :

Re-opening because this one seems to be back again in current bzr head. r1271

Changed in python-mode:
status: Fix Committed → New
Changed in python-mode:
status: New → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.