You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you indent a set of lines which contains a blank line, then arguably any blank lines should not themselves be indented. At least not for most programming languages. So it is arguable as to whether this can be considered an issue within editorcommands.py or its interface with each mode.
To be clear here is an example:
def some_method(arg):
""" A doc string"""
return blah(arg)
In the current implementation the blank line between the doc string and the return statement is indented along with the rest of the method definition, whereas generally we would wish for the blank line to remain blank (for example pep8 would complain about 'trailing whitespace').
I have a solution to this in editorcommands.indent:
s = mode.build_indent_str(cols + mode.indent_width)
self.replace_string(wnd, f, t, s, False)
tol = doc.geteol(tol)
finally:
becomes:
eol = doc.geteol(tol)
if eol != t+1:
s = mode.build_indent_str(cols + mode.indent_width)
self.replace_string(wnd, f, t, s, False)
tol = doc.geteol(tol)
finally:
Before I submit a pull request, does this seem like a reasonable solution? I cannot seem to avoid calling doc.geteol(tol) twice.
Additionally, why does indent not simply call self._indent_line on each line within the selection? If it did then to fix this issue, _indent_line would probably need an argument to say whether it should indent a blank line or not.
The text was updated successfully, but these errors were encountered:
I'm fully agree that blank line should not be indented, and your fix looks good to me.
Using EditCommands._indent_line() on each line of text is okay, but it requires some more changes. Current EditCommands._indent_line() checks if cursor position is in indentation in the line or not. If text is not selected and cursor position is beyond indentation characters, line should not be indent line but simply put tab character at cursor position. I don't think new argument to indent blank line is necessary.
If you indent a set of lines which contains a blank line, then arguably any blank lines should not themselves be indented. At least not for most programming languages. So it is arguable as to whether this can be considered an issue within editorcommands.py or its interface with each mode.
To be clear here is an example:
In the current implementation the blank line between the doc string and the return statement is indented along with the rest of the method definition, whereas generally we would wish for the blank line to remain blank (for example pep8 would complain about 'trailing whitespace').
I have a solution to this in editorcommands.indent:
becomes:
Before I submit a pull request, does this seem like a reasonable solution? I cannot seem to avoid calling
doc.geteol(tol)
twice.Additionally, why does
indent
not simply callself._indent_line
on each line within the selection? If it did then to fix this issue,_indent_line
would probably need an argument to say whether it should indent a blank line or not.The text was updated successfully, but these errors were encountered: