diff --git a/runtime/lua/nvim/dir/fs.lua b/runtime/lua/nvim/dir/fs.lua index 3bcfeee6d2..d599b70ba5 100644 --- a/runtime/lua/nvim/dir/fs.lua +++ b/runtime/lua/nvim/dir/fs.lua @@ -47,7 +47,7 @@ end ---@param path string function M.open_parent_path(path) - if path == '' then + if path == '' or path:find('^%a[%w+.-]*://') then navigate('.') return end diff --git a/test/functional/plugin/dir_spec.lua b/test/functional/plugin/dir_spec.lua index 54f9a6e95c..1f178932c8 100644 --- a/test/functional/plugin/dir_spec.lua +++ b/test/functional/plugin/dir_spec.lua @@ -376,15 +376,23 @@ describe('nvim.dir', function() eq(vim.fs.basename(root) .. '/', api.nvim_get_current_line()) end) - it('maps - to open the current directory from an unnamed buffer', function() + it('maps - to open the current directory from a buffer with no path', function() make_fixture() n.clear({ args_rm = { '--cmd' }, args = { '--clean' } }) local cwd = fn.getcwd() + command('terminal') + eq('terminal', api.nvim_get_option_value('buftype', { buf = 0 })) cd(root) finally(function() cd(cwd) end) + feed('-') + poke_eventloop() + + assert_directory(root) + + command('enew') eq('', api.nvim_buf_get_name(0)) feed('-') poke_eventloop()