Skip to content

Commit

Permalink
fix: set alternate when using floating windows (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
iovis committed Dec 10, 2024
1 parent 3c2de37 commit bbb102f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/")
Expand Down
12 changes: 12 additions & 0 deletions tests/altbuf_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit bbb102f

Please sign in to comment.