stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.37k stars 92 forks source link

bug: alternate not set with `open_float()` #285

Open iovis opened 5 months ago

iovis commented 5 months ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

0.9.5

Operating system/version

macOS 14.2.1

Describe the bug

Looks to be exactly what was happening for https://github.com/stevearc/oil.nvim/issues/60, but when using the floating window. I confirmed the behavior of what was fixed in that PR still worked, but when using require("oil").open_focus() it doesn't seem to set the current buffer as the alternate.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. nvim -u repro.lua
  2. :e somefile1
  3. :lua require('oil').open_float() -- somefile1 is set as alternate
  4. navigate to another file somefile2, and edit it -- somefile1 is set as alternate
  5. :lua require('oil').open_float() -- somefile1 continues to be the alternate, but should be somefile2

Expected Behavior

  1. nvim -u repro.lua
  2. :e somefile1
  3. :lua require('oil').open() -- somefile1 is set as alternate
  4. use oil to navigate to another file somefile2, and edit it -- somefile1 is set as alternate
  5. :lua require('oil').open() -- somefile2 is the alternate
  6. use oil to navigate to somefile2 again, and edit it -- somefile1 is again alternate

Directory structure

No response

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Did you check the bug with a clean config?

tricktux commented 4 months ago

Friendly bump of this issue.

Thanks for an awesome plugin!

pxnditxyr commented 3 months ago

Hello,

I've been following the discussion on this issue (#285) and wanted to report that I am experiencing the same problem when using :Oil --float. Like others have mentioned, the alternate file is not being set correctly.

perryrh0dan commented 4 days ago

Hi,

First of all, thanks for this awesome plugin, really appreciate your efforts.

I am also facing the same issue when using the float window.