From d7f06bfb1381a2741c1bcbadf1bc1e3ed77abea4 Mon Sep 17 00:00:00 2001 From: Kiyan Date: Thu, 21 Jul 2022 13:48:03 +0200 Subject: fix(indents): indents for error block (css, lua) (#3207) --- lua/nvim-treesitter/indent.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lua') 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 -- cgit v1.2.3-70-g09d2