No entry to set "max-line-length" key for formatting in Godot addon settings... And question about .editorconfig
@NathanLovato ci sta già lavorando.
Dal 20/9/2026.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia in plugin.gd, confronta format_code con lint_code e ispeziona get_editorconfig_format_on_save insieme al percorso del file temporaneo. Verifica che la formattazione riceva la lunghezza di riga configurata e che la ricerca di .editorconfig funzioni per i file del progetto. Il lavoro è completato quando entrambe le impostazioni si comportano correttamente durante la formattazione tramite l’addon Godot.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
There is a "Lint Line Length" in addon settings menu which only affects linting. I read plugin.gd and found it was implemented by run the formatter executable with --max-line-length=<max_line_length> flag:
func lint_code(script: GDScript) -> Array:
# ...
var formatter_arguments: Array = ["lint", ProjectSettings.globalize_path(script_path)]
var max_line_length := get_editor_setting(SETTING_LINT_LINE_LENGTH) as int
formatter_arguments.append("--max-line-length")
formatter_arguments.append(str(max_line_length))
# ...
var exit_code := OS.execute(get_editor_setting(SETTING_FORMATTER_PATH), formatter_arguments, output)
# ...
However for format_code function there is no line to add --max-line-length flag. This flag is valid for the executable itself for formatting, and line length is always a important attribute for a formatter, so it's weird the addon settings doesn't have any entry to set it, and it's quite easy to implement it by adding same codes to the format code function. I did so to let Lint Line Length value also affects formatting, and it works fine for me.
Besides .editorconfig file seems not work with addon. I tried formatting gdscript files with formatter executable directly using command lines in terminal, and it can find and use parameters in editor config file in parent directory correctly. So it's also weird that it doesn't work with addon. According to plugin.gd:
func get_editorconfig_format_on_save(script_path: String) -> Variant:
var editorconfig_path := ProjectSettings.globalize_path("res://.editorconfig")
# ...
Seems that it will only try to find editor config file in project root, and it only reads gdscript_formatter_format_on_save parameter from that file, ignoring other parameters. Is it intended?
EDIT:
Just quickly inspected plugin.gd again. Found why it ignores the .editorconfig. When you use the addon in godot editor, it creates a temp file in elsewhere:
var path_temporary_file := OS.get_temp_dir().path_join(
"gdscript_formatter_%d.gd" % Time.get_ticks_msec()
)
The addon will first formats the temp file, then replaces the actual file with it. For my system it creates the temp file in somewhere like c:/temp/, far away from my project directory. When use the executable to format it, it will only search through the temp file folder and temp file's parent folders for .editorconfig. That's why it can't find my project's .editorconfig.
So one of the simplest solutions is just create the temp file in the same folder with the original file you want to format, and it's also easy to implement. Since I'm busy now I may try this method when I have some free time.
- Lingua principale
- Rust
- Stelle
- 468
- Fork
- 39
- Merge medio
- 6h 24m
- PR unite (30g)
- 3
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di GDQuest/GDScript-formatter
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
GDQuest/GDScript-formatter#365 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
GDQuest/GDScript-formatter#366 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
GDQuest/GDScript-formatter#360 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
GDQuest/GDScript-formatter#354 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
GDQuest/GDScript-formatter#353 · 4 commenti ·
Tutte le issue di GDQuest/GDScript-formatter
Issue simili
-
llm translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
CybercentreCanada/sawp#13 ·
-
area: backend type: enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100
armadavalor/WinKnife#6 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
5omeOtherGuy/phaseone#870 ·
I maintainer di solito rispondono entro 1 giorno