fix: schedule vim api calls (#216)
This commit is contained in:
parent
39d54e2674
commit
de29868f54
@ -845,7 +845,7 @@ end
|
|||||||
---@param content string concatenated content of the buffer
|
---@param content string concatenated content of the buffer
|
||||||
---@param opts? {focus?: boolean, stream?: boolean, scroll?: boolean, callback?: fun(): nil} whether to focus the result view
|
---@param opts? {focus?: boolean, stream?: boolean, scroll?: boolean, callback?: fun(): nil} whether to focus the result view
|
||||||
function Sidebar:update_content(content, opts)
|
function Sidebar:update_content(content, opts)
|
||||||
if not self.result or not self.result.bufnr or not api.nvim_buf_is_valid(self.result.bufnr) then
|
if not self.result or not self.result.bufnr then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
opts = vim.tbl_deep_extend("force", { focus = true, scroll = true, stream = false, callback = nil }, opts or {})
|
opts = vim.tbl_deep_extend("force", { focus = true, scroll = true, stream = false, callback = nil }, opts or {})
|
||||||
@ -867,7 +867,7 @@ function Sidebar:update_content(content, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
if not self.result.bufnr or not api.nvim_buf_is_valid(self.result.bufnr) then
|
if not self.result or not self.result.bufnr or not api.nvim_buf_is_valid(self.result.bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
scroll_to_bottom()
|
scroll_to_bottom()
|
||||||
@ -887,7 +887,7 @@ function Sidebar:update_content(content, opts)
|
|||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
if not self.result.bufnr or not api.nvim_buf_is_valid(self.result.bufnr) then
|
if not self.result or not self.result.bufnr or not api.nvim_buf_is_valid(self.result.bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local lines = vim.split(content, "\n")
|
local lines = vim.split(content, "\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user