diff --git a/runtime/doc/plugins.txt b/runtime/doc/plugins.txt index 054b71e8d3..c40705cd07 100644 --- a/runtime/doc/plugins.txt +++ b/runtime/doc/plugins.txt @@ -64,7 +64,7 @@ To disable the built-in directory browser, set this before startup: >lua GLOBAL MAPPINGS *dir-mappings* • - opens the parent directory of the current file or directory. -• {count}- is like -, but a count of 1 opens the current working directory, +• {count}- is like -, but a count of 1 opens the global working directory, and a higher count goes up that many levels. BUFFER-LOCAL MAPPINGS *dir-buffer-mappings* diff --git a/runtime/plugin/dir.lua b/runtime/plugin/dir.lua index 37ce560398..53f7fcff17 100644 --- a/runtime/plugin/dir.lua +++ b/runtime/plugin/dir.lua @@ -12,9 +12,10 @@ end, { silent = true, desc = 'Open directory entry' }) vim.keymap.set('n', '(nvim-dir-up)', function() if vim.v.count == 1 then + -- Edits global CWD api.nvim_cmd({ cmd = 'edit', - args = { '.' }, + args = { vim.fn.getcwd(-1, -1, -1) }, mods = { keepalt = vim.b.nvim_dir ~= nil }, magic = { file = false, bar = false }, }, {}) diff --git a/test/functional/plugin/dir_spec.lua b/test/functional/plugin/dir_spec.lua index bf2787ce78..e7028bb914 100644 --- a/test/functional/plugin/dir_spec.lua +++ b/test/functional/plugin/dir_spec.lua @@ -433,6 +433,13 @@ describe('nvim.dir', function() assert_directory(cwd) + edit(file) + feed('-') + poke_eventloop() + feed('1-') + poke_eventloop() + assert_directory(cwd) + edit(file) feed('2-') poke_eventloop()