From f67eb83be5f8c49f1a7621553458227b786b1b0c Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sun, 23 Jan 2022 13:44:36 -0500 Subject: feat(indent): Implement basic indent for gdscript. Indent is not handled correctly when adding new lines. It seems that functions/loops/etc. are not recognized until they have at least one indented block. For example, if you enter a newline after `func foo():`, the cursor will not be indented. If you manually indent and add a line like `pass`, e.g.: ``` func foo(): pass ``` now any insertions above or below `pass` will be indented correctly. This might be an issue with the grammar, as it seems to apply to highlights as well. The following will not be highligted ``` func foo(): ``` However, the following will be: ``` func foo(): pass ``` --- tests/indent/gdscript_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/indent/gdscript_spec.lua (limited to 'tests/indent/gdscript_spec.lua') diff --git a/tests/indent/gdscript_spec.lua b/tests/indent/gdscript_spec.lua new file mode 100644 index 00000000..c1770f41 --- /dev/null +++ b/tests/indent/gdscript_spec.lua @@ -0,0 +1,20 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/gdscript", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 0, + expandtab = false, +}) + +describe("indent GDScript:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("basic_blocks.gd", { on_line = 1, text = "var member := 0", indent = 0 }) + end) +end) -- cgit v1.2.3