get qflist on errors with message as well
This commit is contained in:
@@ -36,13 +36,31 @@ do
|
|||||||
local orig = debug.traceback
|
local orig = debug.traceback
|
||||||
|
|
||||||
---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
debug.traceback = function(...)
|
debug.traceback = function(thread, message, level)
|
||||||
local trace = full_trace()
|
local trace = vim.split(full_trace(), "\n")
|
||||||
local orig_trace = orig(...) -- TODO remove. find message instead
|
local orig_trace = orig(thread, message, level)
|
||||||
|
if type(thread) ~= 'thread' then
|
||||||
|
level = message
|
||||||
|
message = thread
|
||||||
|
end
|
||||||
|
assert(type(message) == 'nil' or type(message) == 'string')
|
||||||
|
local qflist_items = vim.split(message, "\n")
|
||||||
|
|
||||||
|
-- doing this to remove truncated file location at the start of the error message
|
||||||
|
for i, msg in ipairs(qflist_items) do
|
||||||
|
local match = string.match(msg, ".*:%s*(.*)")
|
||||||
|
if match ~= nil then
|
||||||
|
qflist_items[i] = match
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, loc in ipairs(trace) do
|
||||||
|
table.insert(qflist_items, loc)
|
||||||
|
end
|
||||||
|
|
||||||
vim.fn.setqflist({}, "a", {
|
vim.fn.setqflist({}, "a", {
|
||||||
title = "Traceback",
|
title = "Traceback",
|
||||||
lines = vim.split(trace, "\n"),
|
lines = qflist_items,
|
||||||
})
|
})
|
||||||
|
|
||||||
return orig_trace
|
return orig_trace
|
||||||
|
|||||||
Reference in New Issue
Block a user