question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gdformat collapses multiline-function call in chained function, exceeding line length

See original GitHub issue

This file is formatted correctly:

extends Node


func _physics_process(delta: float):
	var move_target := Vector2(
		Input.get_action_strength("right") - Input.get_action_strength("left"),
		Input.get_action_strength("forward") - Input.get_action_strength("backward")
	)

Now add a method call on the end:

extends Node


func _physics_process(delta: float):
	var move_target := Vector2(
		Input.get_action_strength("right") - Input.get_action_strength("left"),
		Input.get_action_strength("forward") - Input.get_action_strength("backward")
	).rotated(20)

gdformat collapses it into one line, breaking the line length restriction:

extends Node


func _physics_process(delta: float):
	var move_target := Vector2(Input.get_action_strength("right") - Input.get_action_strength("left"), Input.get_action_strength("forward") - Input.get_action_strength("backward")).rotated(
		20
	)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Sconycommented, Oct 21, 2022

fixed on master by f99c69d7b64dac281cac42dd952eb4e54c58e80a

0reactions
Sconycommented, Sep 20, 2021

@rcorre the issues are solved in Godot’s master branch already.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier does not respect existing method chain breaks #7884
I don't think that code expressing chained methods across multiple lines should be automatically collapsed by prettier .
Read more >
How to prevent Visual Studio Code from pushing chained ...
The line length limit is reached; The user opts into it by manually inserting a newline, like object literals.
Read more >
Python: Formatting Chained Methods - Ken Goettler
Chained method calls might be too long for a single line. ... a 79-character line length, the method must be broken up over...
Read more >
489444 – [Formatter] Chained method calls when ... - Bugs
toList()); On the first line of code, I really do want the method calls to be chained together with no line splits. This...
Read more >
Auto-indent lines feature wrongly indents multiline chained ...
Auto-indent lines feature wrongly indents multiline chained method calls ... and the tooltip warns: "PEP8: continuation line unaligned for hanging indent".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found