Closed ghost closed 7 months ago
Well... This comes from the limitation of the language configuration :
These lines define how indentation works with a GDScript file, but there is no way to define a deindentation rule that would fix the issue (since here the rule needs to do 4 deindent, and a rule can only do one). So to fix that issue :
Let me know what you think of this.
we can switch the language definition to use a more complex definition format, like Tree Sitter, which is a huge amount of work.
It would be awesome.
we can remove these lines, and thus removing automatic indentation. Without it, VSCode fallsback to automatic indentation by using brackets. The user still have to manually indent (once, VSCode remembers the last indentation level and indents newlines to it) and deindent.
But this is okay too. I currently disabled language-provided indentation in my workflow.
Might be fixable by using onEnterRules
in the gdscript-configuration.json
. Will have a look soon.
The indent/dedent rules have been modified since this was posted, and with godot-tools 2.0.0
I think it behaves correctly now (or at least better).
I also don't think there's any room for improvement, given the limitations @linkpy outlined.
(Speaking of @linkpy, if you actually know how to implement tree-sitter in a vscode extension please hit me up...)
Steps to reproduce:
following code:
move cursor to line before
var tmp = 5
press enter
newline will indent to the same level as
pass
, when it should indent to same level asvar tmp = 5