GDQuest / GDQuest/GDScript-formatter
Preserve two empty lines when function is commented out
- Dominant language
- Rust
- Stars
- 455
- Forks
- 39
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 4
Description
When you comment out a function in between or after a function, the formatter unnecessarily removes empty lines. Here is an example:
Before:
```gdscript
func f(x: float) -> float:
return x
func g(x: float) -> float:
return x
func h(x: float) -> float:
return x
```
After commenting out middle function:
```gdscript
func f(x: float) -> float:
return x
# func g(x: float) -> float:
# return x
func h(x: float) -> float:
return x
```
---
This 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.