Error on closing outline when computer is running slow
This commit is contained in:
mabubakar
2024-04-23 11:51:57 +05:00
parent bdfd2da90e
commit c593f4756a
2 changed files with 12 additions and 6 deletions

View File

@@ -9,13 +9,17 @@ local M = {
---Clear all highlights in buffer
---@param bufnr integer
function M.clear_all_ns(bufnr)
vim.api.nvim_buf_clear_namespace(bufnr, -1, 0, -1)
if vim.api.nvim_buf_is_valid(bufnr) then
vim.api.nvim_buf_clear_namespace(bufnr, -1, 0, -1)
end
end
---Clear hover highlights in buffer
---@param bufnr integer
function M.clear_hovers(bufnr)
vim.api.nvim_buf_clear_namespace(bufnr, M.ns.hover, 0, -1)
if vim.api.nvim_buf_is_valid(bufnr) then
vim.api.nvim_buf_clear_namespace(bufnr, M.ns.hover, 0, -1)
end
end
---Add single hover highlights

View File

@@ -87,13 +87,15 @@ end
---Replace all lines in buffer with given new `lines`
---@param lines string[]
function View:rewrite_lines(lines)
vim.api.nvim_buf_set_option(self.buf, 'modifiable', true)
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
if vim.api.nvim_buf_is_valid(self.buf) then
vim.api.nvim_buf_set_option(self.buf, 'modifiable', true)
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
end
end
function View:clear_all_ns()
highlight.clear_all_ns(self.buf)
pcall(function() highlight.clear_all_ns(self.buf) end)
end
---Ensure all existing highlights are already cleared before calling!