From f1904f2a6c39a6f3523d5122dffc654d19aae5b4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 11 Jul 2026 13:09:06 +0200 Subject: [PATCH] test(dir): "replace `-` mapping" hangs the Windows CI --- test/functional/plugin/dir_spec.lua | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/functional/plugin/dir_spec.lua b/test/functional/plugin/dir_spec.lua index 53839b2cd1..3e6063cd2c 100644 --- a/test/functional/plugin/dir_spec.lua +++ b/test/functional/plugin/dir_spec.lua @@ -160,20 +160,25 @@ describe('nvim.dir', function() eq('alpha.txt', api.nvim_get_current_line()) end) - it('lets startup plugins replace the - mapping', function() - local config_dir = fn.stdpath('config') - local plugin_dir = vim.fs.joinpath(config_dir, 'plugin') - fn.mkdir(plugin_dir, 'p') - fn.writefile({ - [[if vim.fn.mapcheck('-', 'n') == '' and vim.fn.hasmapto('(dirvish_up)', 'n') == 0 then]], - [[ vim.keymap.set('n', '-', '(dirvish_up)')]], - [[end]], - }, vim.fs.joinpath(plugin_dir, 'dirvish.lua')) + it('startup plugins can replace the `-` mapping', function() + local plugin_file = vim.fs.joinpath(vim.fn.stdpath('config'), 'plugin/dirvish.lua') + vim.fs.mkdir(vim.fs.dirname(plugin_file), { parents = true }) + finally(function() + os.remove(plugin_file) -- XXX: Remove file only, to avoid n.rmdir() hang on Windows. + end) + vim.fn.writefile( + [[ + if vim.fn.mapcheck('-', 'n') == '' and vim.fn.hasmapto('(dirvish_up)', 'n') == 0 then + vim.keymap.set('n', '-', '(dirvish_up)') + end + ]], + plugin_file + ) n.clear({ args_rm = { '-u', '--cmd' } }) + eq(1, fn.exists('g:loaded_nvim_dir_plugin')) -- Avoid false negatives. eq('(dirvish_up)', fn.mapcheck('-', 'n')) - n.rmdir(config_dir) end) it('preserves alternate buffer when opening a parent directory', function()