fix(dap.hover): improve window state management
This commit is contained in:
+15
-11
@@ -54,7 +54,7 @@ function Window.get_instance(session)
|
|||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
function Window:close()
|
function Window:destroy()
|
||||||
if self.winid and vim.api.nvim_win_is_valid(self.winid) then
|
if self.winid and vim.api.nvim_win_is_valid(self.winid) then
|
||||||
vim.api.nvim_win_close(self.winid, true)
|
vim.api.nvim_win_close(self.winid, true)
|
||||||
end
|
end
|
||||||
@@ -63,12 +63,7 @@ function Window:close()
|
|||||||
vim.api.nvim_del_augroup_by_id(self.augroup)
|
vim.api.nvim_del_augroup_by_id(self.augroup)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.max_width = nil
|
instance = nil
|
||||||
self.max_height = nil
|
|
||||||
self.winid = nil
|
|
||||||
self.bufnr = nil
|
|
||||||
self.augroup = nil
|
|
||||||
self.root = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return integer
|
---@return integer
|
||||||
@@ -267,7 +262,7 @@ function Window:show(root)
|
|||||||
buffer = prev_buf,
|
buffer = prev_buf,
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
self:close()
|
self:destroy()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -275,12 +270,21 @@ function Window:show(root)
|
|||||||
group = self.augroup,
|
group = self.augroup,
|
||||||
callback = function(arg)
|
callback = function(arg)
|
||||||
if arg.buf ~= self.bufnr then
|
if arg.buf ~= self.bufnr then
|
||||||
self:close()
|
self:destroy()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("WinClosed", {
|
||||||
|
group = self.augroup,
|
||||||
|
once = true,
|
||||||
|
pattern = tostring(self.winid),
|
||||||
|
callback = function()
|
||||||
|
self:destroy()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Toggle expand/collapse
|
-- Toggle expand/collapse
|
||||||
vim.keymap.set("n", "<CR>", function()
|
vim.keymap.set("n", "<CR>", function()
|
||||||
self:toggle_node()
|
self:toggle_node()
|
||||||
@@ -319,11 +323,11 @@ function Window:show(root)
|
|||||||
|
|
||||||
-- Quick actions
|
-- Quick actions
|
||||||
vim.keymap.set("n", "q", function()
|
vim.keymap.set("n", "q", function()
|
||||||
self:close()
|
self:destroy()
|
||||||
end, { buffer = self.bufnr, nowait = true })
|
end, { buffer = self.bufnr, nowait = true })
|
||||||
|
|
||||||
vim.keymap.set("n", "<Esc>", function()
|
vim.keymap.set("n", "<Esc>", function()
|
||||||
self:close()
|
self:destroy()
|
||||||
end, { buffer = self.bufnr, nowait = true })
|
end, { buffer = self.bufnr, nowait = true })
|
||||||
|
|
||||||
-- Yank operations
|
-- Yank operations
|
||||||
|
|||||||
Reference in New Issue
Block a user