Skip to content

Commit

Permalink
fix(nui): reset close events on remount
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 11, 2022
1 parent 119682b commit 1558c48
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lua/noice/view/nui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ function NuiView:create()
local opts = vim.deepcopy(self._opts)
self._nui = self._opts.type == "split" and require("nui.split")(opts) or require("nui.popup")(opts)

self:mount()
self:update_layout()
self._scroll = Scrollbar({
winnr = self._nui.winid,
padding = Util.nui.normalize_padding(self._opts.border),
})
self._scroll:mount()
self._loading = false
end

function NuiView:mount()
self._nui:mount()
if self._opts.close and self._opts.close.events then
self._nui:on(self._opts.close.events, function()
self:hide()
Expand All @@ -138,16 +150,6 @@ function NuiView:create()
self:hide()
end, { remap = false, nowait = true })
end

self._nui:mount()

self:update_layout()
self._scroll = Scrollbar({
winnr = self._nui.winid,
padding = Util.nui.normalize_padding(self._opts.border),
})
self._scroll:mount()
self._loading = false
end

---@param old NoiceNuiOptions
Expand Down Expand Up @@ -259,7 +261,7 @@ function NuiView:show()
end

if not self._nui._.mounted then
self._nui:mount()
self:mount()
end

vim.bo[self._nui.bufnr].modifiable = true
Expand Down

0 comments on commit 1558c48

Please sign in to comment.