Skip to content

Commit

Permalink
fix(treesitter): normalise end row early
Browse files Browse the repository at this point in the history
Problem:
UINT32_MAX + 1 passed to vim._foldupdate.

Solution:
Normalise the erow from treesitter asap to avoid such issues.
  • Loading branch information
tomtomjhj committed Apr 22, 2024
1 parent 1590e21 commit 7ace3ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/lua/vim/treesitter/_fold.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ end
---@param parse_injections? boolean
local function compute_folds_levels(bufnr, info, srow, erow, parse_injections)
srow = srow or 0
erow = normalise_erow(bufnr, erow)
erow = erow or api.nvim_buf_line_count(bufnr)

local parser = ts.get_parser(bufnr)

Expand Down Expand Up @@ -316,6 +316,7 @@ local function on_changedtree(bufnr, foldinfo, tree_changes)
local srow_upd, erow_upd ---@type integer?, integer?
for _, change in ipairs(tree_changes) do
local srow, _, erow, ecol = Range.unpack4(change)
erow = normalise_erow(bufnr, erow)
if ecol > 0 then
erow = erow + 1
end
Expand Down

0 comments on commit 7ace3ff

Please sign in to comment.