fix: don't take over the preview window until it's opened for oil (#532)

This commit is contained in:
Gustavo Sampaio 2024-12-21 01:15:47 -03:00 committed by GitHub
parent dba0375988
commit 78ab7ca107
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -668,10 +668,17 @@ M.hack_around_termopen_autocmd = function(prev_mode)
end, 10)
end
---@param opts? {include_not_owned?: boolean}
---@return nil|integer
M.get_preview_win = function()
M.get_preview_win = function(opts)
opts = opts or {}
for _, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
if vim.api.nvim_win_is_valid(winid) and vim.wo[winid].previewwindow then
if
vim.api.nvim_win_is_valid(winid)
and vim.wo[winid].previewwindow
and (opts.include_not_owned or vim.w[winid]["oil_preview"])
then
return winid
end
end