fix(refresh): correct refresh in code buffer (#166)
only render inlay in codebuf Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
1cbf7e106c
commit
2fc266edd2
@ -93,7 +93,7 @@ H.autocmds = function()
|
||||
local s = M.sidebars[tab]
|
||||
local sl = M.selections[tab]
|
||||
if s then
|
||||
s:destroy()
|
||||
s:reset()
|
||||
end
|
||||
if sl then
|
||||
sl:delete_autocmds()
|
||||
@ -177,6 +177,7 @@ M.refresh = function()
|
||||
|
||||
local curwin = vim.api.nvim_get_current_win()
|
||||
|
||||
sidebar:close()
|
||||
sidebar.code.winid = curwin
|
||||
sidebar.code.bufnr = curbuf
|
||||
sidebar:render()
|
||||
|
@ -65,27 +65,33 @@ function Selection:setup_autocmds()
|
||||
api.nvim_create_autocmd({ "ModeChanged" }, {
|
||||
group = self.augroup,
|
||||
pattern = { "n:v", "n:V", "n:" }, -- Entering Visual mode from Normal mode
|
||||
callback = function()
|
||||
callback = function(ev)
|
||||
if vim.bo[ev.buf].filetype ~= "Avante" then
|
||||
self:show_hints_popup()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
group = self.augroup,
|
||||
callback = function()
|
||||
callback = function(ev)
|
||||
if vim.bo[ev.buf].filetype ~= "Avante" then
|
||||
if vim.fn.mode() == "v" or vim.fn.mode() == "V" or vim.fn.mode() == "" then
|
||||
self:show_hints_popup()
|
||||
else
|
||||
self:close_hints_popup()
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd({ "ModeChanged" }, {
|
||||
group = self.augroup,
|
||||
pattern = { "v:n", "v:i", "v:c" }, -- Switching from visual mode back to normal, insert, or other modes
|
||||
callback = function()
|
||||
callback = function(ev)
|
||||
if vim.bo[ev.buf].filetype ~= "Avante" then
|
||||
self:close_hints_popup()
|
||||
end
|
||||
end,
|
||||
})
|
||||
return self
|
||||
|
@ -58,11 +58,6 @@ function Sidebar:new(id)
|
||||
}, { __index = self })
|
||||
end
|
||||
|
||||
--- This function should only be used on TabClosed, nothing else.
|
||||
function Sidebar:destroy()
|
||||
self:reset()
|
||||
end
|
||||
|
||||
function Sidebar:delete_autocmds()
|
||||
if self.augroup then
|
||||
api.nvim_del_augroup_by_id(self.augroup)
|
||||
@ -85,13 +80,13 @@ end
|
||||
function Sidebar:open()
|
||||
local in_visual_mode = Utils.in_visual_mode() and self:in_code_win()
|
||||
if not self:is_open() then
|
||||
self:destroy()
|
||||
self:reset()
|
||||
self:intialize()
|
||||
self:render()
|
||||
else
|
||||
if in_visual_mode then
|
||||
self:close()
|
||||
self:destroy()
|
||||
self:reset()
|
||||
self:intialize()
|
||||
self:render()
|
||||
return self
|
||||
|
Loading…
x
Reference in New Issue
Block a user