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 19, 2024
1 parent 3c2de37 commit 7c1f27b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ M.select = function(opts, callback)
vertical = opts.vertical,
horizontal = opts.horizontal,
split = opts.split,
keepalt = true,
keepalt = false,
}
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("#"))
test_util.feedkeys({ "/LICENSE<CR>" }, 10)
oil.select()
test_util.wait_for_autocmd("BufEnter")
assert.equals("LICENSE", vim.fn.expand("%:."))
assert.equals("foo", vim.fn.expand("#"))
end)
end)
end)

0 comments on commit 7c1f27b

Please sign in to comment.