Skip to content

Commit

Permalink
fix(buffer): clear namespace on render
Browse files Browse the repository at this point in the history
Extmarks could build up when replacing notifications which could hugely
decrease performance over time.

See #71
  • Loading branch information
rcarriga committed Mar 20, 2022
1 parent 2c93e29 commit da10302
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/notify/service/buffer/init.lua
Expand Up @@ -94,8 +94,10 @@ function NotificationBuf:render()
local notif = self._notif
local buf = self._buffer

local render_namespace = require("notify.render.base").namespace()
api.nvim_buf_set_option(buf, "filetype", "notify")
api.nvim_buf_set_option(buf, "modifiable", true)
api.nvim_buf_clear_namespace(buf, render_namespace, 0, -1)

notif.render(buf, notif, self.highlights)

Expand All @@ -106,7 +108,6 @@ function NotificationBuf:render()
for _, line in pairs(lines) do
width = math.max(width, vim.str_utfindex(line))
end
local render_namespace = require("notify.render.base").namespace()
local success, extmarks = pcall(
api.nvim_buf_get_extmarks,
buf,
Expand Down

0 comments on commit da10302

Please sign in to comment.