Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter silently breaks with leading minus sign in multiline statement #717

Open
cjmaxik opened this issue Sep 16, 2024 · 4 comments
Open

Comments

@cjmaxik
Copy link

cjmaxik commented Sep 16, 2024

Godot version

v4.3.stable.official [77dcf97d8]

VS Code version

1.93.1

Godot Tools VS Code extension version

2.1.0

System information

Windows 11

Issue description

If one uses a multiline statement and one of the lines has a leading minus sign, the formatter silently breaks.

Steps to reproduce

The following examples will break the formatter.

var test1 := deg_to_rad(
	-90
)

var test2 := Vector2(
	-0.0,
	1.0
)

var test3 := Vector3(
	0.0,
	-0.0,
	0.0
)

func get_audio_compensation() -> float:
	return AudioServer.get_time_since_last_mix() \
		- AudioServer.get_output_latency() \
		+ (1 / Engine.get_frames_per_second()) * 2
@cjmaxik cjmaxik added the bug label Sep 16, 2024
@cjmaxik cjmaxik changed the title Formatter silently breaks with leading minus sign in multiline function Formatter silently breaks with leading minus sign in multiline statement Sep 16, 2024
@nemoDreamer
Copy link

Oh my God, that's it!!! I had a file that stopped getting formatted, and I couldn't for the life of me figure out what in my config was causing this to happen...!

😆 🤣 😢

@DaelonSuzuka
Copy link
Collaborator

Correctly detecting this situation might be approaching the limits of this formatter, but I might be able to make it continue formatting even if there's a problem....

@DaelonSuzuka
Copy link
Collaborator

I expected this to be difficult because the textmate tokenizer doesn't preserve a lot of context across lines, but it was actually a simple index-out-of-bounds error because the - is the 0th token and token n-1 doesn't exist.

This will be fixed in the next release.

@nemoDreamer
Copy link

nemoDreamer commented Nov 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants