From b0611b5330a4a4b5c722bf5fcd99cd56386df5b7 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 6 Sep 2023 13:21:43 +0800 Subject: [PATCH] perf(spinners): handle spinners function error --- lua/spacevim/api/unicode/spinners.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/spacevim/api/unicode/spinners.lua b/lua/spacevim/api/unicode/spinners.lua index 7b02e170c..da6e4a9c0 100644 --- a/lua/spacevim/api/unicode/spinners.lua +++ b/lua/spacevim/api/unicode/spinners.lua @@ -8,6 +8,8 @@ local M = {} +local log = require('spacevim.logger').derive('spinners') + M._data = { dot1 = { frames = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, @@ -24,7 +26,13 @@ function M.Onframe(...) else M.index = 1 end - M.func(M.spinners[M.index]) + if type(M.func) == 'function' then + local ok, err = pcall(M.func, M.spinners[M.index]) + if not ok then + log.debug('failed to call spinners functions:\n') + log.debug(err) + end + end end function M.stop()