fix(health): floating window closes when opening TOC (gO) #34794

Problem: Health check floating window gets closed when pressing 'gO' to show TOC because LSP floating preview system auto-closes on BufEnter events triggered by :lopen.

Solution: Temporarily disable BufEnter event for the current window during TOC operations and adjust window layout to prevent overlap.
This commit is contained in:
glepnir
2025-07-08 20:21:09 +08:00
committed by GitHub
parent f68a5c40f0
commit 28b7c2df52
5 changed files with 29 additions and 8 deletions

View File

@@ -1422,10 +1422,17 @@ local function close_preview_autocmd(events, winnr, bufnrs)
-- close the preview window when entered a buffer that is not
-- the floating window buffer or the buffer that spawned it
api.nvim_create_autocmd('BufEnter', {
api.nvim_create_autocmd('BufLeave', {
group = augroup,
buffer = bufnrs[1],
callback = function()
close_preview_window(winnr, bufnrs)
vim.schedule(function()
-- When jumping to the quickfix window from the preview window,
-- do not close the preview window.
if api.nvim_get_option_value('filetype', { buf = 0 }) ~= 'qf' then
close_preview_window(winnr, bufnrs)
end
end)
end,
})