From 9caef3a2f4ab95fd152c24971b204cf65f8cb4af Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 13 Jun 2026 01:32:50 +0200 Subject: [PATCH 1/3] fix(health): check more "old" files --- runtime/lua/vim/health/health.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/health/health.lua b/runtime/lua/vim/health/health.lua index 0fa218772d..2b26baf3bd 100644 --- a/runtime/lua/vim/health/health.lua +++ b/runtime/lua/vim/health/health.lua @@ -41,6 +41,8 @@ local function check_runtime() ['lua/vim/shared.lua'] = false, ['plugin/health.vim'] = false, ['plugin/man.vim'] = false, + ['plugin/nvim/net.lua'] = false, + ['plugin/nvim/spellfile.lua'] = false, ['queries/help/highlights.scm'] = false, ['queries/help/injections.scm'] = false, ['scripts.vim'] = false, @@ -176,7 +178,7 @@ local function check_watchers() local a = vim._watch.active local total = a.watch + a.watchdirs + a.inotify health.info( - ('filewatchers (vim._watch): %d (watch=%d, watchdirs=%d, inotify=%d)'):format( + ('Filewatchers (vim._watch): %d (watch=%d, watchdirs=%d, inotify=%d)'):format( total, a.watch, a.watchdirs, From 07f02ae8de7037e42a7b8b3296f2c3a787b2682a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 14 Jun 2026 23:11:49 +0200 Subject: [PATCH 2/3] test: cleanup mksession_spec --- runtime/doc/news.txt | 2 +- test/functional/ex_cmds/mksession_spec.lua | 47 +++------------------- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 966cc9291a..c6e596079f 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -187,9 +187,9 @@ EVENTS • |:delmarks| now triggers the |MarkSet| autocommand with line==col==0, same as |nvim_buf_del_mark()| +• |SessionWritePre| event emits just before |:mksession|. • |TextPutPre| and |TextPutPost| are triggered before/after putting text. • |TabMoved| is triggered when tabs are reordered. -• Added the |SessionWritePre| autocommand event. HIGHLIGHTS diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 2fd9e524fc..3b4d17377b 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -272,73 +272,39 @@ describe(':mksession', function() it('fires SessionWritePre autocmd', function() command('autocmd SessionWritePre * let g:session_write_pre = 1') - command('mksession ' .. session_file) - eq(1, api.nvim_eval('g:session_write_pre')) end) it('SessionWritePre handles editing buffer contents', function() local tmpfile = file_prefix .. '-tmpfile-float' - command('edit ' .. tmpfile) - command("autocmd SessionWritePre * call append(0, 'foo') | write") - command('mksession ' .. session_file) clear() command('source ' .. session_file) - - eq(2, api.nvim_buf_line_count(0)) - - eq({ 'foo', '' }, api.nvim_buf_get_lines(0, 0, 2, true)) - + eq({ 'foo', '' }, api.nvim_buf_get_lines(0, 0, -1, true)) os.remove(tmpfile) end) it('SessionWritePre handles switching buffers', function() command('autocmd SessionWritePre * new') - command('mksession ' .. session_file) clear() command('source ' .. session_file) -- both buffers are saved - eq(2, vim.tbl_count(api.nvim_list_bufs())) + eq(2, #api.nvim_list_bufs()) end) - it('SessionWritePre handles bwipeout', function() + it('SessionWritePre handles buffer removal', function() + -- :bdelete and :bwipeout differ for "live" Nvim but are equivalent + -- from :mksession's perspective, so one test covers both. api.nvim_buf_set_name(0, 'foo') - command('autocmd SessionWritePre * bwipeout!') - command('mksession ' .. session_file) - -- old buffer is gone - eq('', api.nvim_buf_get_name(0)) - - clear() - command('source ' .. session_file) - -- gone for good - eq( - nil, - vim.iter(api.nvim_list_bufs()):find(function(b) - return api.nvim_buf_get_name(b) == 'foo' - end) - ) - end) - - it('SessionWritePre handles bdelete', function() - api.nvim_buf_set_name(0, 'foo') - - command('autocmd SessionWritePre * bdelete!') - - command('mksession ' .. session_file) - - -- old buffer is gone - eq('', api.nvim_buf_get_name(0)) - clear() command('source ' .. session_file) -- gone for good @@ -352,12 +318,11 @@ describe(':mksession', function() it('SessionWritePre handles splits', function() command('autocmd SessionWritePre * split | vsplit') - command('mksession ' .. session_file) clear() command('source ' .. session_file) -- contains all splits - eq(3, vim.tbl_count(api.nvim_tabpage_list_wins(0))) + eq(3, #api.nvim_tabpage_list_wins(0)) end) end) From c18a63a462d23268bd44105ab48cf279fb664e6b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 16 Jun 2026 18:40:13 +0200 Subject: [PATCH 3/3] refactor(test): move swapfile test --- test/functional/core/startup_spec.lua | 43 -------------- .../swapfile_preserve_recover_spec.lua | 58 ++++++++++++++++--- 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index c3b12638a3..bc7e2dcf80 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -118,49 +118,6 @@ describe('startup', function() command('filetype detect') eq('filetype detection:ON plugin:OFF indent:OFF', exec_capture('filetype')) end) - - it('opens swapfile when using device path #31606', function() - t.skip(not is_os('win'), 'N/A: Windows feature') - local cwd = vim.fs.normalize(vim.uv.cwd()) - local drive, path = cwd:sub(1, 1), cwd:sub(3) - local swapdir = ('%s/Xtest_swap_dir'):format(cwd) - local dos_path = ('%s/file.txt'):format(cwd) - local device_quest_path = ('//?/%s'):format(dos_path) - clear({ - args = { - '--embed', - '--headless', - '--cmd', - ('set directory=%s//'):format(swapdir), - '--', - device_quest_path, - }, - merge = false, - }) - local escaped_name = ('%s/%s.swp'):format(swapdir, dos_path:gsub('[:/]', '%%')) - eq(escaped_name, fn.swapname('%')) - - command('bw!') - api.nvim_buf_set_name(0, dos_path) - eq(escaped_name, fn.swapname('%')) - - command('bw!') - local device_dot_path = ('//./%s'):format(dos_path) - api.nvim_buf_set_name(0, device_dot_path) - eq(escaped_name, fn.swapname('%')) - - command('bw!') - local device_unc_path = ('//?/UNC/localhost/%s$%s/file.txt'):format(drive, path) - api.nvim_buf_set_name(0, device_unc_path) - eq(('%s/%%%s.swp'):format(swapdir, device_unc_path:sub(8):gsub('/', '%%')), fn.swapname('%')) - - command('bw!') - -- Volume GUID form, like \\?\Volume{d4857377-2ac4-45d8-a4cb-9b2e447fd02e}\ - local guid = vim.fs.normalize(vim.trim(vim.fn.system(('mountvol %s: /L'):format(drive)))) - local device_guid_path = ('%s%s/file.txt'):format(guid, path:sub(2)) - api.nvim_buf_set_name(0, device_guid_path) - eq(escaped_name, fn.swapname('%')) - end) end) describe('startup', function() diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 84a3bebfe0..4a235dd3f3 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -248,13 +248,12 @@ describe('swapfile detection', function() write_file( testfile, [[ -vim.o.foldmethod = 'expr' -vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()' -vim.defer_fn(function() - vim.api.nvim__redraw({ valid = false }) -end, 500) -pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') - ]] + vim.o.foldmethod = 'expr' + vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + vim.defer_fn(function() + vim.api.nvim__redraw({ valid = false }) + end, 500) + pcall(vim.cmd.edit, 'Xtest_swapredraw.lua')]] ) exec(init) command('edit! ' .. testfile) @@ -729,3 +728,48 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() expect_exitcode(1) end) end) + +describe('swapfile', function() + it('when using device path #31606', function() + t.skip(not is_os('win'), 'N/A: Windows feature') + local cwd = vim.fs.normalize(vim.uv.cwd()) + local drive, path = cwd:sub(1, 1), cwd:sub(3) + local swapdir = ('%s/Xtest_swap_dir'):format(cwd) + local dos_path = ('%s/file.txt'):format(cwd) + local device_quest_path = ('//?/%s'):format(dos_path) + clear({ + args = { + '--embed', + '--headless', + '--cmd', + ('set directory=%s//'):format(swapdir), + '--', + device_quest_path, + }, + merge = false, + }) + local escaped_name = ('%s/%s.swp'):format(swapdir, dos_path:gsub('[:/]', '%%')) + eq(escaped_name, fn.swapname('%')) + + command('bw!') + api.nvim_buf_set_name(0, dos_path) + eq(escaped_name, fn.swapname('%')) + + command('bw!') + local device_dot_path = ('//./%s'):format(dos_path) + api.nvim_buf_set_name(0, device_dot_path) + eq(escaped_name, fn.swapname('%')) + + command('bw!') + local device_unc_path = ('//?/UNC/localhost/%s$%s/file.txt'):format(drive, path) + api.nvim_buf_set_name(0, device_unc_path) + eq(('%s/%%%s.swp'):format(swapdir, device_unc_path:sub(8):gsub('/', '%%')), fn.swapname('%')) + + command('bw!') + -- Volume GUID form, like \\?\Volume{d4857377-2ac4-45d8-a4cb-9b2e447fd02e}\ + local guid = vim.fs.normalize(vim.trim(vim.fn.system(('mountvol %s: /L'):format(drive)))) + local device_guid_path = ('%s%s/file.txt'):format(guid, path:sub(2)) + api.nvim_buf_set_name(0, device_guid_path) + eq(escaped_name, fn.swapname('%')) + end) +end)