Regression: Python docstrings fail wrapping
The new version wrapping Python docstrings adds * prefix to lines, if the comment starts on the docstring line.
Input:
def a():
""" a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a """
Output:
def a():
""" a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
* a a a a """
Looks like it is added by this ancient hack makes sense for C-style comments but not for Python i.e. not if firstLineIsDocstring.
if (i > 0 && firstLineIsCommentOpener) {
// This is a hack. We don't know how much whitespace to use!
lineIndent = "$whitespaceBeforeOpener * "
}
Fix:
if (i > 0 && firstLineIsCommentOpener && !firstLineIsDocstring) {
// This is a hack. We don't know how much whitespace to use!
lineIndent = "$whitespaceBeforeOpener * "
}
Wrapping (at least Wrap Line to Column) was not adding these asterix in earlier versions, though you'll have a better understanding of why it was so. I'm not making a pull request because of this unclarity.
Experiencing the same issue. PyCharm version: 2024.2.1. Plugin version: 1.9.1.
I have the same issue in IntelliJ IDEA 2024.2.2 with Python plugin (242.22855.74) and Wrap To Column plugin 1.9.1
@edgarsi You say "ancient hack", but this is a recent regression... Could you elaborate?
@rogerdahl Recent versions unified much of the line wrapping and paragraph wrapping code. This C hack was not called before, at least not for line wrapping. I'm 95% sure this hack still makes sense after unification, but it needs the fix proposed.
I would also really like this to be fixed! Definitely bugging me in python code. Also the new version's settings page gets stuck on the loading spinner for me.
@edgarsi Maybe you should just do that PR? Wrapping in Python is already broken and it seems unlikely that it will break things even more, given that only Python has docstrings.
#66
The bug was deeper than initially guessed.