diff options
| author | Daniel Woznicki <danwoz@nettoolkit.com> | 2022-03-18 14:13:27 -0700 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-03-19 12:29:36 +0100 |
| commit | b1380560a0f8fe339109ac33840eea5b0ac91cc4 (patch) | |
| tree | 7c71e7dcef0c94b0a6ddd306c62f2a0647e2bfd1 | |
| parent | edit(readme): note about the configuration filetypes (diff) | |
| download | nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.tar nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.tar.gz nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.tar.bz2 nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.tar.lz nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.tar.xz nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.tar.zst nvim-treesitter-b1380560a0f8fe339109ac33840eea5b0ac91cc4.zip | |
Added fix for incorrect CSS indent after closing bracket
Added a failing test for possible broken CSS syntax tree
| -rw-r--r-- | queries/css/indents.scm | 5 | ||||
| -rw-r--r-- | tests/indent/css/block.css | 1 | ||||
| -rw-r--r-- | tests/indent/css/closing.css | 1 | ||||
| -rw-r--r-- | tests/indent/css/next_rule.css | 3 | ||||
| -rw-r--r-- | tests/indent/css_spec.lua | 28 |
5 files changed, 35 insertions, 3 deletions
diff --git a/queries/css/indents.scm b/queries/css/indents.scm index 8b725022d..1ea8a336f 100644 --- a/queries/css/indents.scm +++ b/queries/css/indents.scm @@ -3,8 +3,7 @@ (declaration) ] @indent -[ - "}" -] @branch +(block ("}") @branch) +("}") @dedent (comment) @ignore diff --git a/tests/indent/css/block.css b/tests/indent/css/block.css new file mode 100644 index 000000000..cc79c2c06 --- /dev/null +++ b/tests/indent/css/block.css @@ -0,0 +1 @@ +.testo { diff --git a/tests/indent/css/closing.css b/tests/indent/css/closing.css new file mode 100644 index 000000000..cc79c2c06 --- /dev/null +++ b/tests/indent/css/closing.css @@ -0,0 +1 @@ +.testo { diff --git a/tests/indent/css/next_rule.css b/tests/indent/css/next_rule.css new file mode 100644 index 000000000..ae18f1bd7 --- /dev/null +++ b/tests/indent/css/next_rule.css @@ -0,0 +1,3 @@ +.testo { + color: green; +} diff --git a/tests/indent/css_spec.lua b/tests/indent/css_spec.lua new file mode 100644 index 000000000..3d758ebac --- /dev/null +++ b/tests/indent/css_spec.lua @@ -0,0 +1,28 @@ +local Runner = require("tests.indent.common").Runner +local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/css", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent CSS:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("closing.css", { on_line = 1, text = "}", indent = 0 }) + run:new_line( + "block.css", + { on_line = 1, text = "color: green;", indent = 2 }, + "might fail because tree is in a broken state", + XFAIL + ) + run:new_line("next_rule.css", { on_line = 3, text = ".next {", indent = 0 }) + end) +end) |
