remove whitespace

This commit is contained in:
Ivar Fatland
2026-04-18 16:08:35 +02:00
parent ee62fe23d5
commit c5de994706
-10
View File
@@ -10,31 +10,25 @@ vim.g.python3_host_prog = get_python_venv_path()
do do
local function full_trace() local function full_trace()
local lines = {} local lines = {}
local level = 2 local level = 2
while true do while true do
local info = debug.getinfo(level, "Sln") local info = debug.getinfo(level, "Sln")
if not info then break end if not info then break end
local src = info.source or "?" local src = info.source or "?"
local file = src:gsub("^@", "") -- remove @ prefix local file = src:gsub("^@", "") -- remove @ prefix
local line = string.format( local line = string.format(
"%s:%d: in %s", "%s:%d: in %s",
file, file,
info.currentline or 0, info.currentline or 0,
info.name or "?" info.name or "?"
) )
table.insert(lines, line) table.insert(lines, line)
level = level + 1 level = level + 1
end end
return table.concat(lines, "\n") return table.concat(lines, "\n")
end end
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(thread, message, level) debug.traceback = function(thread, message, level)
local trace = vim.split(full_trace(), "\n") local trace = vim.split(full_trace(), "\n")
@@ -45,7 +39,6 @@ do
end end
assert(type(message) == 'nil' or type(message) == 'string') assert(type(message) == 'nil' or type(message) == 'string')
local qflist_items = vim.split(message, "\n") local qflist_items = vim.split(message, "\n")
-- doing this to remove truncated file location at the start of the error message -- doing this to remove truncated file location at the start of the error message
for i, msg in ipairs(qflist_items) do for i, msg in ipairs(qflist_items) do
local match = string.match(msg, ".*:%s*(.*)") local match = string.match(msg, ".*:%s*(.*)")
@@ -53,16 +46,13 @@ do
qflist_items[i] = match qflist_items[i] = match
end end
end end
for _, loc in ipairs(trace) do for _, loc in ipairs(trace) do
table.insert(qflist_items, loc) table.insert(qflist_items, loc)
end end
vim.fn.setqflist({}, "a", { vim.fn.setqflist({}, "a", {
title = "Traceback", title = "Traceback",
lines = qflist_items, lines = qflist_items,
}) })
return orig_trace return orig_trace
end end
end end