Skip to content

Commit

Permalink
fix: spinner freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
kawre committed Feb 22, 2024
1 parent 0ee58f2 commit 7cf551b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion lua/leetcode-ui/renderer/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ end

function Menu:apply_options()
api.nvim_buf_set_name(self.bufnr, "")
pcall(vim.diagnostic.disable, self.bufnr)

utils.set_buf_opts(self.bufnr, {
modifiable = false,
Expand Down
20 changes: 10 additions & 10 deletions lua/leetcode/logger/spinner/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,16 @@ local spinners = {
---@private
function spinner:spin()
local stype = self.spinner
if not stype then return end

if stype then
self:set(nil, nil, {
icon = stype.frames[self.index + 1],
})
self:set(nil, nil, {
icon = stype.frames[self.index + 1],
})

self.index = (self.index + 1) % #stype.frames
self.index = (self.index + 1) % #stype.frames

local fps = 1000 / #stype.frames
vim.defer_fn(function() self:spin() end, fps)
end
local fps = 1000 / #stype.frames
vim.defer_fn(function() self:spin() end, fps)
end

---@private
Expand All @@ -64,10 +63,11 @@ function spinner:set(msg, lvl, opts)
if msg then self:update(msg) end
lvl = lvl or vim.log.levels.INFO

opts = vim.tbl_deep_extend("force", self.noti and { replace = self.noti } or {}, {
opts = vim.tbl_deep_extend("force", {
hide_from_history = true,
title = config.name,
timeout = false,
replace = self.noti,
}, opts or {})

self.noti = vim.notify(self.msg, lvl, opts)
Expand All @@ -92,7 +92,7 @@ function spinner:stop(msg, success, opts)

opts = vim.tbl_deep_extend("force", {
icon = success and "" or "󰅘",
timeout = 2000,
timeout = 1500,
}, opts or {})

self.spinner = nil
Expand Down

0 comments on commit 7cf551b

Please sign in to comment.