From 2d72963f8f7243bfe624a085d7145d27d21170d7 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 7 Feb 2026 00:50:02 -0500 Subject: [PATCH] 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. --- lua/diffs/debug.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/diffs/debug.lua b/lua/diffs/debug.lua index 5be95bc..c234c32 100644 --- a/lua/diffs/debug.lua +++ b/lua/diffs/debug.lua @@ -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 })