-
-
Notifications
You must be signed in to change notification settings - Fork 21
Description
When you comment out a function in between or after a function, the formatter unnecessarily removes empty lines. Here is an example:
Before:
func f(x: float) -> float:
return x
func g(x: float) -> float:
return x
func h(x: float) -> float:
return xAfter commenting out middle function:
func f(x: float) -> float:
return x
# func g(x: float) -> float:
# return x
func h(x: float) -> float:
return xThis violates the official style guide which says:
Surround functions and class definitions with two blank lines
This also annoyingly bobs functions up and down as you temporarily comment them out, which is not ideal. I assume the problem here is that the formatter treats commented sections following a function as part of the function itself, and thus tries to use a single empty line.
At least on VSCode, comments made with CTRL + / respect the indent level of the commented code. So, it should be possible to detect whether a comment is part of the function or part of a codeblock outside the function using the indent level. However, I am not sure if this convention is universal.