godot-gdscript-toolkit
godot-gdscript-toolkit copied to clipboard
GDFormat removes some lines completely but not in a consistent manner
I'm using GDFormat in VS Code with the extension and in works really well, except that some lines (mostly at the end of functions) get deleted completely. The amount of lines doesn't seem to matter either. Sometimes it's 1 line; sometimes it's multiple lines. It also doesn't happen with every function, but about with 20% to 30% for each script file.
Example 1 (one line is deleted): Before
func add_actions(arr_info: Array):
for info in arr_info:
add_action(info)
arr_info.clear()
After
func add_actions(arr_info: Array):
for info in arr_info:
add_action(info)
Example 2 (two lines get deleted): Before
func _add_key_action(p_name: String, p_scancode, p_modifiers: Array, p_extra: Array):
var iek:= InputEventKey.new()
iek.scancode = p_scancode
_set_modifiers(iek, p_modifiers)
_set_key_extras(iek, p_extra)
InputMap.add_action(p_name)
InputMap.action_add_event(p_name, iek)
After
func _add_key_action(p_name: String, p_scancode, p_modifiers: Array, p_extra: Array):
var iek:= InputEventKey.new()
iek.scancode = p_scancode
_set_modifiers(iek, p_modifiers)
_set_key_extras(iek, p_extra)
VS Code version: 1.66.2 Plugin version: tried both from VS Code Marketplace and latest from github (3.4.0)
@kidinashell could you please try formatting the same from command line? gdformat <path-to-file> I'm curious if it fails there as well.
Also, could you please try downgrading gdtoolkit like pip3 install 'gdtoolkit==3.3.1 and then trying again in VS Code?
@Scony Problem persists in VS Code with both versions. In console the problem doesn't occur with any version. Is it possible, that the Formatter extensions in VS Code also does make use of the parser to rearrange the functions alphabetical? Because that's the functionality I want to make most use of and the console command gdformat only seems to format and not organize the script.
Ok, and @kidinashell what python version do you use?
I use 3.10.4