diff options
| author | Kiyan <yazdani.kiyan@protonmail.com> | 2022-07-21 13:48:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-21 13:48:03 +0200 |
| commit | d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4 (patch) | |
| tree | eac4f46b175c67afbe488a874854913667c319d2 /lua | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.tar nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.tar.gz nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.tar.bz2 nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.tar.lz nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.tar.xz nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.tar.zst nvim-treesitter-d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4.zip | |
fix(indents): indents for error block (css, lua) (#3207)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/indent.lua | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lua/nvim-treesitter/indent.lua b/lua/nvim-treesitter/indent.lua index dd3b2b876..0eac0a911 100644 --- a/lua/nvim-treesitter/indent.lua +++ b/lua/nvim-treesitter/indent.lua @@ -149,12 +149,19 @@ function M.get_indent(lnum) end -- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum) + local should_process = not is_processed_by_row[srow] + local is_in_err = false + if should_process then + local parent = node:parent() + is_in_err = parent and parent:has_error() + end if - not is_processed_by_row[srow] - -- Dear stylua, please don't change the semantics of this statement! - -- stylua: ignore start - and (q.indent[node:id()] and srow ~= erow and ((srow ~= lnum - 1) or q.indent[node:id()].start_at_same_line)) - -- stylua: ignore end + should_process + and ( + q.indent[node:id()] + and (srow ~= erow or is_in_err) + and (srow ~= lnum - 1 or q.indent[node:id()].start_at_same_line) + ) then indent = indent + indent_size is_processed = true |
