Skip to content

Commit 52e407a

Browse files
authored
prevent notification from freezing (#172)
* prevent notification from freezing * remove unnecessary assignment
1 parent 0826010 commit 52e407a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lua/package-info/ui/generic/loading-status.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,12 @@ M.stop = function(id, message, level)
108108
[vim.log.levels.WARN] = "",
109109
}
110110

111-
local new_notif = vim.notify(message, level, {
111+
vim.notify(message, level, {
112112
title = title,
113113
icon = level_icon[level],
114114
replace = M.state.notification,
115115
timeout = config.options.timeout,
116116
})
117-
M.state.notification = new_notif
118117
M.state.notification = nil
119118
end
120119

@@ -125,7 +124,9 @@ M.stop = function(id, message, level)
125124
table.insert(filtered_list, instance)
126125
end
127126
end
128-
127+
if #filtered_list == 0 then
128+
M.reset_state()
129+
end
129130
M.queue = filtered_list
130131
end
131132

@@ -168,6 +169,10 @@ M.get = function()
168169
return instance.message
169170
end
170171
end
172+
return ""
173+
end
174+
175+
M.reset_state = function()
171176
M.state.is_running = false
172177
M.state.current_spinner = ""
173178
M.state.index = 1
@@ -183,7 +188,5 @@ M.get = function()
183188
})
184189
end)
185190
end
186-
return ""
187191
end
188-
189192
return M

0 commit comments

Comments
 (0)