fix(lua): don't remove first char of non-file stacktrace source (#37008)

This commit is contained in:
zeertzjq
2025-12-18 08:09:16 +08:00
parent df9452ea9e
commit 275c769f01
4 changed files with 4 additions and 4 deletions

View File

@@ -1323,7 +1323,7 @@ local function traceback()
if not info then
break
end
local msg = (' %s:%s'):format(info.source:sub(2), info.currentline)
local msg = (' %s:%s'):format(info.source:gsub('^@', ''), info.currentline)
table.insert(backtrace, msg)
level = level + 1
end

View File

@@ -492,7 +492,7 @@ function M._profile(opts)
if opts and opts.loaders then
for l, loader in pairs(loaders) do
local loc = debug.getinfo(loader, 'Sn').source:sub(2)
local loc = debug.getinfo(loader, 'Sn').source:gsub('^@', '')
loaders[l] = track('loader ' .. l .. ': ' .. loc, loader)
end
end

View File

@@ -841,7 +841,7 @@ end
--- @return string
local function get_script_path()
local str = debug.getinfo(2, 'S').source:sub(2)
local str = debug.getinfo(2, 'S').source:gsub('^@', '')
return str:match('(.*[/\\])') or './'
end

View File

@@ -1176,7 +1176,7 @@ describe('user config init', function()
string.format(
[[
vim.g.exrc_file = "%s"
vim.g.exrc_path = debug.getinfo(1, 'S').source:sub(2)
vim.g.exrc_path = debug.getinfo(1, 'S').source:gsub('^@', '')
]],
exrc_path
)