aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2023-04-03 23:47:41 +0900
committerStephan Seitz <stephan.seitz@fau.de>2023-04-08 09:56:06 -0700
commit474c59dcf1d5586d6ef0d3f91b380c6c25eb314b (patch)
tree19d156bee39b9246be68bb6a450a77628924010e /lua
parentfix(indent): Make indent ignore trailing spaces/comment (diff)
downloadnvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.gz
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.bz2
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.lz
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.xz
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.zst
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.zip
add test
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/indent.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/lua/nvim-treesitter/indent.lua b/lua/nvim-treesitter/indent.lua
index 7b3485341..fc11b4063 100644
--- a/lua/nvim-treesitter/indent.lua
+++ b/lua/nvim-treesitter/indent.lua
@@ -138,15 +138,15 @@ function M.get_indent(lnum)
-- The final node we capture of the previous line can be a comment node, which should also be ignored
-- Unless the last line is an entire line of comment, ignore the comment range and find the last node again
local first_node = get_first_node_at_line(root, prevlnum, indent)
+ local _, scol, _, _ = node:range()
if first_node:id() ~= node:id() then
-- In case the last captured node is a trailing comment node, re-trim the string
- prevline = vim.trim(prevline:sub(1, node:start() + 1 - indent))
+ prevline = vim.trim(prevline:sub(1, scol - indent))
-- Add back indent as indent of prevline was trimmed away
local col = indent + #prevline - 1
node = get_last_node_at_line(root, prevlnum, col)
end
end
-
if q.indent["end"][node:id()] then
node = get_first_node_at_line(root, lnum)
end