Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Preserve two empty lines when function is commented out

Aperta
#208 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
rust
Ambito
tooling

Direzione di ricerca

Riproduci il comportamento del formatter con l’esempio GDScript dell’issue, quindi traccia come vengono gestiti i commenti, l’indentazione e le righe vuote intorno ai confini delle funzioni. Verifica se il formatter distingue tra corpi di funzione commentati e commenti tra le funzioni. Il lavoro è completo quando vengono preservate due righe vuote intorno alla funzione commentata, mantenendo il comportamento di formattazione esistente nel resto del codice.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 x

After commenting out middle function:

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.

Lingua principale
Rust
Stelle
458
Fork
40
Merge medio
1g 15h
PR unite (30g)
4

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GDQuest/GDScript-formatter

Tutte le issue di GDQuest/GDScript-formatter

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.