From 53c79ddc28b0df3263d629f5e20c9283b05841ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=8D=E7=94=9F=E8=8A=B1?= Date: Tue, 9 Jul 2024 10:12:29 +0900 Subject: [PATCH] fix(php): do not indent after class/enum decl --- queries/php_only/indents.scm | 6 ++++++ tests/indent/php/issue-6888.php | 12 ++++++++++++ tests/indent/php_spec.lua | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 tests/indent/php/issue-6888.php diff --git a/queries/php_only/indents.scm b/queries/php_only/indents.scm index 4a67a8b0b..fef026757 100644 --- a/queries/php_only/indents.scm +++ b/queries/php_only/indents.scm @@ -40,6 +40,12 @@ (compound_statement "}" @indent.end) +(declaration_list + "}" @indent.end) + +(enum_declaration_list + "}" @indent.end) + (return_statement ";" @indent.end) diff --git a/tests/indent/php/issue-6888.php b/tests/indent/php/issue-6888.php new file mode 100644 index 000000000..950cb8119 --- /dev/null +++ b/tests/indent/php/issue-6888.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/tests/indent/php_spec.lua b/tests/indent/php_spec.lua index 3fc681c29..2a41079ff 100644 --- a/tests/indent/php_spec.lua +++ b/tests/indent/php_spec.lua @@ -62,5 +62,10 @@ describe("indent PHP:", function() run:new_line("issue-4848.php", { on_line = 64, text = "return $a;", indent = 12 }) run:new_line("issue-4848.php", { on_line = 65, text = "$a,", indent = 8 }) run:new_line("issue-4848.php", { on_line = 66, text = "$a;", indent = 0 }) + run:new_line("issue-6888.php", { on_line = 2, text = "$a;", indent = 0 }) + run:new_line("issue-6888.php", { on_line = 3, text = "case Funday = 2;", indent = 4 }) + run:new_line("issue-6888.php", { on_line = 6, text = "$a;", indent = 0 }) + run:new_line("issue-6888.php", { on_line = 8, text = "$a;", indent = 4 }) + run:new_line("issue-6888.php", { on_line = 11, text = "$a;", indent = 0 }) end) end)