Skip to content

Commit

Permalink
feat: handle manually closed window
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarriga committed Aug 4, 2021
1 parent 542ef38 commit bc18fb4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lua/notify/render.lua
Expand Up @@ -130,7 +130,11 @@ function NotificationRenderer:advance_stage(win)
elseif cur_stage == WinStage.OPEN then
self.win_stages[win] = WinStage.CLOSING
else
api.nvim_win_close(win, true)
local success = pcall(api.nvim_win_close, win, true)
if not success then
self:remove_win_state(win)
return
end
local notif = self.notifications[win]
self:remove_win_state(win)
if notif.on_close then
Expand All @@ -154,11 +158,12 @@ end
function NotificationRenderer:update_states(time)
local updated_states = {}
for win, _ in pairs(self.win_stages) do
updated_states[win] = vim.tbl_map(function(state)
return animate.spring(time, state)
end, self:stage_state(
win
))
local states = self:stage_state(win)
if states then
updated_states[win] = vim.tbl_map(function(state)
return animate.spring(time, state)
end, states)
end
end
self.win_states = updated_states
end
Expand Down

0 comments on commit bc18fb4

Please sign in to comment.