From 3ec7e3094e28b45831f58a414c91c780f7cbfa53 Mon Sep 17 00:00:00 2001 From: Giuseppe Gadola Date: Fri, 24 Feb 2023 11:16:14 +0100 Subject: fix: handle window/tab switches Reload the popup when window/buffer is changed or there is any similar error. Related to #17 and #19. --- lua/pets/animations.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua index 1b9d93d..b413578 100644 --- a/lua/pets/animations.lua +++ b/lua/pets/animations.lua @@ -125,12 +125,17 @@ function M.Animation:next_frame() M.Animation.set_next_col(self) 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") + if self.current_image then + self.current_image:delete() + end + if not self.hidden then + self.popup:mount() + self:start() + end end self.current_image = image end -- cgit v1.3-2-g11bf