diff options
| author | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-17 12:27:24 +0100 |
|---|---|---|
| committer | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-17 12:27:24 +0100 |
| commit | 67aef69c75a4e797b4fb4848722e6e749d3fbe89 (patch) | |
| tree | e35111212ced94284091e8ab7c791628421b5858 | |
| parent | Adding statefulness when toggling settings (diff) | |
fix(toggles): fix pause after hide
Fixed the pets not pausing after being hidden and unhidden.
Also fixed an hologram error found in the process
| -rw-r--r-- | lua/pets.lua | 2 | ||||
| -rw-r--r-- | lua/pets/animations.lua | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lua/pets.lua b/lua/pets.lua index 282a147..cf76f0f 100644 --- a/lua/pets.lua +++ b/lua/pets.lua @@ -108,6 +108,8 @@ function M.toggle_hide() hidden = not hidden if hidden then -- Hiding relies on the pets being paused as well paused = true + else + paused = false end for _, pet in pairs(M.pets) do pet:set_hidden(hidden) diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua index 9bbe97d..7b9cf17 100644 --- a/lua/pets/animations.lua +++ b/lua/pets/animations.lua @@ -15,7 +15,7 @@ for _ = 0, 20 do end local listdir = require("pets.utils").listdir -local sleeping_animations = {'idle', 'sit', 'liedown'} +local sleeping_animations = { "idle", "sit", "liedown" } local function get_sleeping_animation() return sleeping_animations[math.random(#sleeping_animations)] @@ -104,9 +104,10 @@ function M.Animation:next_frame() self.frame_counter = self.frame_counter + 1 -- pouplate the buffer with spaces to avoid image distortion - if vim.api.nvim_buf_is_valid(self.popup.bufnr) then - vim.api.nvim_buf_set_lines(self.popup.bufnr, 0, -1, false, lines) + if not vim.api.nvim_buf_is_valid(self.popup.bufnr) then + return end + vim.api.nvim_buf_set_lines(self.popup.bufnr, 0, -1, false, lines) if not self.current_image then self.frame_counter = 1 else @@ -205,7 +206,8 @@ function M.Animation:set_state(new_state) self.popup:mount() self:start() end - elseif new_state.paused ~= nil then + end + if new_state.paused ~= nil then if self.state.paused then self:stop_timer() else |