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:
parent
8d4602dbcb
commit
2d72963f8f
1 changed files with 5 additions and 3 deletions
|
|
@ -18,14 +18,16 @@ function M.dump()
|
||||||
end_col = details.end_col,
|
end_col = details.end_col,
|
||||||
hl_group = details.hl_group,
|
hl_group = details.hl_group,
|
||||||
priority = details.priority,
|
priority = details.priority,
|
||||||
|
hl_eol = details.hl_eol,
|
||||||
line_hl_group = details.line_hl_group,
|
line_hl_group = details.line_hl_group,
|
||||||
number_hl_group = details.number_hl_group,
|
number_hl_group = details.number_hl_group,
|
||||||
virt_text = details.virt_text,
|
virt_text = details.virt_text,
|
||||||
}
|
}
|
||||||
if not by_line[row] then
|
local key = tostring(row)
|
||||||
by_line[row] = { text = lines[row + 1] or '', marks = {} }
|
if not by_line[key] then
|
||||||
|
by_line[key] = { text = lines[row + 1] or '', marks = {} }
|
||||||
end
|
end
|
||||||
table.insert(by_line[row].marks, entry)
|
table.insert(by_line[key].marks, entry)
|
||||||
end
|
end
|
||||||
|
|
||||||
local all_ns_marks = vim.api.nvim_buf_get_extmarks(bufnr, -1, 0, -1, { details = true })
|
local all_ns_marks = vim.api.nvim_buf_get_extmarks(bufnr, -1, 0, -1, { details = true })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue