feat: Indent backslash continuation lines according to style guide#218
Merged
NathanLovato merged 2 commits intoGDQuest:mainfrom Apr 11, 2026
Merged
feat: Indent backslash continuation lines according to style guide#218NathanLovato merged 2 commits intoGDQuest:mainfrom
NathanLovato merged 2 commits intoGDQuest:mainfrom
Conversation
From gdscript style guide[^1]:
> Use 2 indent levels to distinguish continuation lines from regular code blocks.
Currently the formatter indents continuation lines to the same level as
the first line:
```gdscript
func test(thing):
thing.calling(1) \
.a(12314) \
.long() \
.chain("a string breaks things") \
.of() \
.functions()
```
With this change, continuation lines (joined with a backslash) are
formatted with double indention:
```gdscript
func test(thing):
thing.calling(1) \
.a(12314) \
.long() \
.chain("a string breaks things") \
.of() \
.functions()
```
fixes GDQuest#180
[^1]: https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html#indentation
Contributor
|
Thank you very much for the contribution! Have you tried with queries before using a regular expression? Regular expressions should generally be a last resort for when something cannot be solved with queries because it's too easy to miss some context like nested functions etc. I'll try on my end |
Contributor
|
Thank you for the help. I always appreciate people taking time to attempt a fix. In general, the only thing is we should favor using queries or modifying the parsed tree with plain procedural code and move away from regular expressions, because while they're very convenient and look short, using them is very prone to edge cases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements:
Related issue (if applicable): #180
What kind of change does this PR introduce?
Feature, implement proper line continuation indention.
From gdscript style guide1:
Does this PR introduce a breaking change?
It does change the indentation of one existing test. I don't consider that breaking, but it's unclear.
New feature or change
What is the current behavior?
Currently the formatter indents continuation lines to the same level as the first line:
What is the new behavior?
With this change, continuation lines (joined with a backslash) are formatted with double indention:
Other information
Footnotes
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html#indentation ↩