mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
fix: always close keymap help window
This commit is contained in:
parent
1dda335878
commit
17f97fd2ca
1 changed files with 17 additions and 1 deletions
|
@ -85,7 +85,7 @@ M.show_help = function(keymaps)
|
|||
|
||||
local editor_width = vim.o.columns
|
||||
local editor_height = vim.o.lines - vim.o.cmdheight
|
||||
vim.api.nvim_open_win(bufnr, true, {
|
||||
local winid = vim.api.nvim_open_win(bufnr, true, {
|
||||
relative = "editor",
|
||||
row = math.max(0, (editor_height - #lines) / 2),
|
||||
col = math.max(0, (editor_width - max_line - 1) / 2),
|
||||
|
@ -95,6 +95,22 @@ M.show_help = function(keymaps)
|
|||
style = "minimal",
|
||||
border = "rounded",
|
||||
})
|
||||
local function close()
|
||||
if vim.api.nvim_win_is_valid(winid) then
|
||||
vim.api.nvim_win_close(winid, true)
|
||||
end
|
||||
end
|
||||
vim.api.nvim_create_autocmd("BufLeave", {
|
||||
callback = close,
|
||||
once = true,
|
||||
nested = true,
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("WinLeave", {
|
||||
callback = close,
|
||||
once = true,
|
||||
nested = true,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in a new issue