From b0a1d35f69b4cd94c46cf957ef45e4d239b0295e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Feb 2025 15:33:11 +0800 Subject: fix(eval): don't shorten $HOME in v:stacktrace (#32634) --- test/functional/ex_cmds/source_spec.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 40225784f5..dba158962f 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -292,3 +292,29 @@ describe(':source', function() os.remove(test_file) end) end) + +it('$HOME is not shortened in filepath in v:stacktrace from sourced file', function() + local sep = n.get_pathsep() + local xhome = table.concat({ vim.uv.cwd(), 'Xhome' }, sep) + mkdir(xhome) + clear({ env = { HOME = xhome } }) + finally(function() + rmdir(xhome) + end) + local filepath = table.concat({ xhome, 'Xstacktrace.vim' }, sep) + local script = [[ + func Xfunc() + throw 'Exception from Xfunc' + endfunc + ]] + write_file(filepath, script) + exec('source ' .. filepath) + exec([[ + try + call Xfunc() + catch + let g:stacktrace = v:stacktrace + endtry + ]]) + eq(filepath, n.eval('g:stacktrace[-1].filepath')) +end) -- cgit