fix(debug): resolve sparse array crash in json dump

Problem: vim.json.encode fails with "excessively sparse array" when
extmark row numbers are used as integer table keys, since they create
gaps in the array.

Solution: use tostring(row) as keys instead. Also add hl_eol to dumped
extmark fields for debugging line background extmarks.
This commit is contained in:
Barrett Ruth 2026-02-07 00:50:02 -05:00
parent 8d4602dbcb
commit 2d72963f8f

View file

@ -18,14 +18,16 @@ function M.dump()
end_col = details.end_col,
hl_group = details.hl_group,
priority = details.priority,
hl_eol = details.hl_eol,
line_hl_group = details.line_hl_group,
number_hl_group = details.number_hl_group,
virt_text = details.virt_text,
}
if not by_line[row] then
by_line[row] = { text = lines[row + 1] or '', marks = {} }
local key = tostring(row)
if not by_line[key] then
by_line[key] = { text = lines[row + 1] or '', marks = {} }
end
table.insert(by_line[row].marks, entry)
table.insert(by_line[key].marks, entry)
end
local all_ns_marks = vim.api.nvim_buf_get_extmarks(bufnr, -1, 0, -1, { details = true })