From 68ab44277cd3eca7c5f1d227f153bd4e56d6303f Mon Sep 17 00:00:00 2001 From: SzeLamC Date: Sat, 25 Feb 2023 05:06:31 +0800 Subject: [PATCH] fix(dart): add `@indent_end` to } (#4167) * fix dart indentation after } * add some simple test case --- queries/dart/indents.scm | 4 ++++ tests/indent/dart/class.dart | 4 ++++ tests/indent/dart_spec.lua | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/indent/dart/class.dart create mode 100644 tests/indent/dart_spec.lua diff --git a/queries/dart/indents.scm b/queries/dart/indents.scm index e01cc238d..ad0ba389e 100644 --- a/queries/dart/indents.scm +++ b/queries/dart/indents.scm @@ -21,6 +21,10 @@ "]" ] @branch +[ + "}" +] @indent_end + ; this one is for dedenting the else block (if_statement (block) @branch) diff --git a/tests/indent/dart/class.dart b/tests/indent/dart/class.dart new file mode 100644 index 000000000..0402cc677 --- /dev/null +++ b/tests/indent/dart/class.dart @@ -0,0 +1,4 @@ +void main() { +} +class Test { +} diff --git a/tests/indent/dart_spec.lua b/tests/indent/dart_spec.lua new file mode 100644 index 000000000..8b05cc753 --- /dev/null +++ b/tests/indent/dart_spec.lua @@ -0,0 +1,20 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/dart", { + tabstop = 4, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent Lua:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) +end) + +describe("new line:", function() + run:new_line("class.dart", { on_line = 2, text = "var x;", indent = 0 }) +end)