diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 72d5538a..83e172ab 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -718,7 +718,6 @@ M.select = function(opts, callback) vertical = opts.vertical, horizontal = opts.horizontal, split = opts.split, - keepalt = true, } local filebufnr = vim.fn.bufadd(normalized_url) local entry_is_file = not vim.endswith(normalized_url, "/") diff --git a/tests/altbuf_spec.lua b/tests/altbuf_spec.lua index 4b516045..c7d3b582 100644 --- a/tests/altbuf_spec.lua +++ b/tests/altbuf_spec.lua @@ -141,5 +141,17 @@ a.describe("Alternate buffer", function() oil.close() assert.equals("foo", vim.fn.expand("#")) end) + + a.it("preserves alternate when traversing to a new file", function() + vim.cmd.edit({ args = { "foo" } }) + oil.open_float() + test_util.wait_for_autocmd({ "User", pattern = "OilEnter" }) + assert.equals("foo", vim.fn.expand("#")) + local last_item = vim.fn.line("$") + vim.api.nvim_win_set_cursor(0, { last_item, 5 }) + oil.select() + test_util.wait_for_autocmd("BufEnter") + assert.equals("foo", vim.fn.expand("#")) + end) end) end)