GDQuest / GDQuest/GDScript-formatter

Preserve two empty lines when function is commented out

Aperta
#208 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
455
Fork
39
Merge medio
1g 15h
PR unite (30g)
4

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.