GDQuest / GDQuest/GDScript-formatter
Preserve two empty lines when function is commented out
- Lenguaje dominante
- Rust
- Estrellas
- 455
- Forks
- 39
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 4
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduce el comportamiento del formateador con el ejemplo de GDScript del issue y, a continuación, rastrea cómo se gestionan los comentarios, la indentación y las líneas en blanco alrededor de los límites de las funciones. Comprueba si el formateador distingue entre cuerpos de función comentados y comentarios entre funciones. Se considera terminado cuando se conservan dos líneas en blanco alrededor de la función comentada, manteniendo el comportamiento de formato existente en el resto.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100