fix: add open_float params to toggle_float (#716)

* feat: `toggle_float` now takes the same params as `open_float`

* docs: update `toggle_float` docs for `opts` and `cb` params

* fix: ensure cb is always called

---------

Co-authored-by: Steven Arcangeli <506791+stevearc@users.noreply.github.com>
This commit is contained in:
zeta-squared 2026-01-17 16:01:02 +11:00 committed by GitHub
parent 6b59a6cf62
commit 7a09f0b000
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 10 deletions

View file

@ -342,11 +342,16 @@ end
---Open oil browser in a floating window, or close it if open
---@param dir nil|string When nil, open the parent of the current buffer, or the cwd if current buffer is not a file
M.toggle_float = function(dir)
---@param opts? oil.OpenOpts
---@param cb? fun() Called after the oil buffer is ready
M.toggle_float = function(dir, opts, cb)
if vim.w.is_oil_win then
M.close()
if cb then
cb()
end
else
M.open_float(dir)
M.open_float(dir, opts, cb)
end
end