mirror of
https://github.com/neovim/neovim.git
synced 2026-08-01 05:09:08 +00:00
fix(treesitter): clamp unbounded fold ranges
Problem:
Tree-sitter uses UINT32_MAX for full-document ranges, which becomes -1 on 32-bit platforms and reaches _foldupdate as an invalid end row.
Solution:
Treat negative changed-range end rows as unbounded and clamp them to the buffer line count. Add a regression test that simulates the 32-bit sentinel.
AI-assisted: Codex
(cherry picked from commit 20ff82d9fc)
This commit is contained in:
committed by
github-actions[bot]
parent
9f3f326acd
commit
e37405ea52
@@ -295,9 +295,10 @@ local function on_changedtree(bufnr, tree_changes)
|
||||
local srow, _, erow, ecol = Range.unpack4(change)
|
||||
-- If a parser doesn't have any ranges explicitly set, treesitter will
|
||||
-- return a range with end_row and end_bytes with a value of UINT32_MAX,
|
||||
-- so clip end_row to the max buffer line.
|
||||
-- which is represented as -1 on 32-bit platforms, so clip end_row to
|
||||
-- the max buffer line.
|
||||
-- TODO(lewis6991): Handle this generally
|
||||
if erow > max_erow then
|
||||
if erow > max_erow or erow < 0 then
|
||||
erow = max_erow
|
||||
elseif ecol > 0 then
|
||||
erow = erow + 1
|
||||
|
||||
Reference in New Issue
Block a user