aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authoroxalica <oxalicc@pm.me>2021-11-27 08:28:40 +0800
committerKiyan <yazdani.kiyan@protonmail.com>2021-11-28 14:52:06 +0100
commit6407d54092490ab33c9a19806e0938a2c9d5fdb8 (patch)
treeee2cec43dc087f2148378b1c2f216e26c0320f13 /lua
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.tar
nvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.tar.gz
nvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.tar.bz2
nvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.tar.lz
nvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.tar.xz
nvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.tar.zst
nvim-treesitter-6407d54092490ab33c9a19806e0938a2c9d5fdb8.zip
fix: off-by-one errors in indent calculation
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/indent.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/lua/nvim-treesitter/indent.lua b/lua/nvim-treesitter/indent.lua
index af08bcd6f..ebf7695de 100644
--- a/lua/nvim-treesitter/indent.lua
+++ b/lua/nvim-treesitter/indent.lua
@@ -54,7 +54,8 @@ function M.get_indent(lnum)
return -1
end
- local root, _, lang_tree = tsutils.get_root_for_position(lnum, 0, parser)
+ -- get_root_for_position is 0-based.
+ local root, _, lang_tree = tsutils.get_root_for_position(lnum - 1, 0, parser)
-- Not likely, but just in case...
if not root then
@@ -114,8 +115,10 @@ function M.get_indent(lnum)
local prev_row = node:start()
while node do
- -- do not indent if we are inside an @ignore block
- if q.ignores[node_fmt(node)] and node:start() < lnum - 1 and node:end_() > lnum - 1 then
+ -- Do not indent if we are inside an @ignore block.
+ -- If a node spans from L1,C1 to L2,C2, we know that lines where L1 < line <= L2 would
+ -- have their indentations contained by the node.
+ if q.ignores[node_fmt(node)] and node:start() < lnum - 1 and lnum - 1 <= node:end_() then
return -1
end