mirror of
https://github.com/neovim/neovim.git
synced 2026-08-02 04:51:38 +08:00
fix(dir): "-" on a non-file buffer opens a bogus path #41034
This commit is contained in:
parent
4bba83b4b7
commit
0d36e61d70
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user