godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.6k stars 170 forks source link

Various Formatter Improvements #746

Closed DaelonSuzuka closed 1 week ago

DaelonSuzuka commented 3 weeks ago

This introduces a new syntax for defining snapshot tests, and fixes at least #717, #734, #728.

Snapshot tests can now be defined in a single file using "blocks":

# --- IN ---
var  a  =   10
# --- OUT ---
var a = 10

I also FINALLY found a solution to remove leading empty newlines from blocks:

# --- IN ---
func test():

    pass
# --- OUT ---
func test():
    pass

# --- IN ---
class Test:

    func _ready():

        pass
# --- OUT ---
class Test:
    func _ready():
        pass
limbonaut commented 3 weeks ago

Breaks on lines in a multiline string:

func dump() -> String:
    return """
    {
        level_file: '%s',
        md5_hash: %s,
        text: '%s',
        level_size: %s,
        world_pos: %s,
        preview_size: %s,
        preview_pos: %s,
        preview_texture: %s,
        explorer_layer: %s,
        connections: %s,
    }
    """ % [level_file, md5_hash, text, level_size, world_pos, preview_size, preview_pos, preview_texture, explorer_layer, connections]

👇

func dump() -> String:
    return """
    {
        level_file: '%s',
        md5_hash:%s,
        text: '%s',
        level_size:%s,
        world_pos:%s,
        preview_size:%s,
        preview_pos:%s,
        preview_texture:%s,
        explorer_layer:%s,
        connections:%s,
    }
    """ % [level_file, md5_hash, text, level_size, world_pos, preview_size, preview_pos, preview_texture, explorer_layer, connections]
DaelonSuzuka commented 3 weeks ago

Thanks @limbonaut! That one's fixed now.

limbonaut commented 3 weeks ago

An issue with quotes and unique name specifier:

@onready var main_menu: Button = %"Main Menu"

👇

@onready var main_menu: Button = % "Main Menu"
limbonaut commented 3 weeks ago

That's all I found. Nice to see the old issues fixed, and it's shaping up to be a really solid formatter.