mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 21:37:43 +00:00
fix(health): floating window closes when opening TOC (gO)
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.
(cherry picked from commit 28b7c2df52)
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2ddb5d21bb
commit
c97ad3cb41
@@ -83,8 +83,9 @@ local get_headings = function(bufnr)
|
||||
return headings
|
||||
end
|
||||
|
||||
--- @param qf_height? integer height of loclist window
|
||||
--- Shows an Outline (table of contents) of the current buffer, in the loclist.
|
||||
function M.show_toc()
|
||||
function M.show_toc(qf_height)
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local bufname = api.nvim_buf_get_name(bufnr)
|
||||
local headings = get_headings(bufnr)
|
||||
@@ -102,7 +103,7 @@ function M.show_toc()
|
||||
end
|
||||
vim.fn.setloclist(0, headings, ' ')
|
||||
vim.fn.setloclist(0, {}, 'a', { title = 'Table of contents' })
|
||||
vim.cmd.lopen()
|
||||
vim.cmd.lopen({ count = qf_height })
|
||||
vim.w.qf_toc = bufname
|
||||
-- reload syntax file after setting qf_toc variable
|
||||
vim.bo.filetype = 'qf'
|
||||
|
||||
Reference in New Issue
Block a user