godot-gdscript-toolkit icon indicating copy to clipboard operation
godot-gdscript-toolkit copied to clipboard

Preserve indentation when checking trailing-whitespace

Open danikaze opened this issue 3 months ago • 0 comments

When you have a function with different "blocks" of code like this ( symbolizes the tabs like in the godot editor)

func ():
→ statement1
→ statement2
→
→ if condition:
→ → do this
→ else:
→ → do that
→ → do that too
→ →
→ → also this
→
→ continue here

where there are empty lines (before the if and after the if) to make the code more readable, the current whitespace checks will require those empty line to be actually empty, while it makes more sense to preserve the indentation of the function or it will look like the function code has been ended.

Request: To add this behavior or a configuration option for the trailing-whitespace rule accepting this new option in gdlint. Something like mode: absolute | indented or similar, to be able to preserve the current behavior and the new behavior.

The same goes for gdformat, so empty lines inside certain level of indentation are not removed, but left with the correct indentation.

danikaze avatar Sep 27 '25 02:09 danikaze