aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/indent.lua17
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