aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/pets/animations.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua
index a330cec..1b9d93d 100644
--- a/lua/pets/animations.lua
+++ b/lua/pets/animations.lua
@@ -102,7 +102,6 @@ end
-- @function called on every tick from the timer, go to the next frame
function M.Animation:next_frame()
self.frame_counter = self.frame_counter + 1
-
-- pouplate the buffer with spaces to avoid image distortion
if self.popup.bufnr == nil or not vim.api.nvim_buf_is_valid(self.popup.bufnr) then
return
@@ -124,7 +123,15 @@ function M.Animation:next_frame()
-- frames contains the images for every action
local image = self.frames[self.current_action][self.frame_counter]
M.Animation.set_next_col(self)
- image:display(self.row, self.col, self.popup.bufnr, {})
+ local ok = pcall(image.display, image, self.row, self.col, self.popup.bufnr, {})
+ if not ok then
+ require("pets").hidden = true
+ self:stop()
+ if self.popup then
+ self.popup:unmount()
+ end
+ utils.warning("Something went wrong, pets are hidden")
+ end
self.current_image = image
end