Skip to content

Commit

Permalink
Merge pull request #80365 from dalexeev/gds-allow-mix-indent-on-blank…
Browse files Browse the repository at this point in the history
…-lines

GDScript: Allow mixed indentation on blank lines
  • Loading branch information
akien-mga committed Aug 17, 2023
2 parents 8d0c9a4 + 00ad9e4 commit e71ec0b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
18 changes: 9 additions & 9 deletions modules/gdscript/gdscript_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,15 +1162,6 @@ void GDScriptTokenizer::check_indent() {
_advance();
}

if (mixed && !(line_continuation || multiline_mode)) {
Token error = make_error("Mixed use of tabs and spaces for indentation.");
error.start_line = line;
error.start_column = 1;
error.leftmost_column = 1;
error.rightmost_column = column;
push_error(error);
}

if (_is_at_end()) {
// Reached the end with an empty line, so just dedent as much as needed.
pending_indents -= indent_level();
Expand Down Expand Up @@ -1214,6 +1205,15 @@ void GDScriptTokenizer::check_indent() {
continue;
}

if (mixed && !line_continuation && !multiline_mode) {
Token error = make_error("Mixed use of tabs and spaces for indentation.");
error.start_line = line;
error.start_column = 1;
error.leftmost_column = 1;
error.rightmost_column = column;
push_error(error);
}

if (line_continuation || multiline_mode) {
// We cleared up all the whitespace at the beginning of the line.
// But if this is a continuation or multiline mode and we don't want any indentation change.
Expand Down
2 changes: 2 additions & 0 deletions modules/gdscript/tests/scripts/parser/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.{gd,out}]
trim_trailing_whitespace = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Empty line:


# Comment line:
# Comment.

func test():
print(1)

if true:

# Empty line:


print(2)

# Comment line:
# Comment.

print(3)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
GDTEST_OK
1
2
3

0 comments on commit e71ec0b

Please sign in to comment.