mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(debug): truncate inspect to 2000 lines max
This commit is contained in:
parent
41ee33725e
commit
570d2191d5
1 changed files with 10 additions and 1 deletions
|
@ -12,6 +12,8 @@ M.meta = {
|
|||
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
local MAX_INSPECT_LINES = 2000
|
||||
|
||||
vim.schedule(function()
|
||||
Snacks.util.set_hl({
|
||||
Indent = "LineNr",
|
||||
|
@ -40,7 +42,14 @@ function M.inspect(...)
|
|||
end
|
||||
vim.schedule(function()
|
||||
local title = "Debug: " .. vim.fn.fnamemodify(caller.source:sub(2), ":~:.") .. ":" .. caller.linedefined
|
||||
Snacks.notify.warn(vim.inspect(len == 1 and obj[1] or len > 0 and obj or nil), { title = title, ft = "lua" })
|
||||
local lines = vim.split(vim.inspect(len == 1 and obj[1] or len > 0 and obj or nil), "\n")
|
||||
if #lines > MAX_INSPECT_LINES then
|
||||
local c = #lines
|
||||
lines = vim.list_slice(lines, 1, MAX_INSPECT_LINES)
|
||||
lines[#lines + 1] = ""
|
||||
lines[#lines + 1] = (c - MAX_INSPECT_LINES) .. " more lines have been truncated …"
|
||||
end
|
||||
Snacks.notify.warn(lines, { title = title, ft = "lua" })
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue