Skip to content

Commit

Permalink
Add support for multiline 'preload' formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Dec 18, 2022
1 parent 548c373 commit 0287c4a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [latest]

### Added
- Added support for multiline `preload` expression formatting (was fixed in Godot)

## [3.4.0] 2022-04-21

### Added
Expand Down
7 changes: 2 additions & 5 deletions gdtoolkit/formatter/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@ def format_comma_separated_list(
multiline_mode_forced = is_expression_forcing_multiple_lines(
fake_expression, context.standalone_comments
)
if not multiline_mode_forced or "preload" in expression_context.prefix_string:
if not multiline_mode_forced:
strings_to_join = list(map(standalone_expression_to_str, elements))
single_line_expression = "{}{}{}".format(
expression_context.prefix_string,
", ".join(strings_to_join),
expression_context.suffix_string,
)
single_line_length = len(single_line_expression) + context.indent
if (
single_line_length <= context.max_line_length
or "preload" in expression_context.prefix_string
):
if single_line_length <= context.max_line_length:
return [
(
expression_context.prefix_line,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = preload("class-stmt-chain.in.gd")
const Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = preload('class-stmt-chain.in.gd')
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = preload(
'class-stmt-chain.in.gd'
"class-stmt-chain.in.gd"
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var x = preload(
'xxx'
'./empty.gd'
)

0 comments on commit 0287c4a

Please sign in to comment.