Skip to content

Commit

Permalink
fix(install): fix NPE in first installation (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
linrongbin16 committed Nov 21, 2023
1 parent 20ce6ce commit 2871108
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lua/colorbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,17 @@ local function _init()
end

local function _policy_shuffle()
local r = math.floor(math.fmod(randint(), #ColorNames))
local color = ColorNames[r + 1]
-- logger.debug(
-- "|colorbox._policy_shuffle| color:%s, ColorNames:%s (%d), r:%d",
-- vim.inspect(color),
-- vim.inspect(ColorNames),
-- vim.inspect()
-- )
vim.cmd(string.format([[color %s]], color))
if #ColorNames > 0 then
local r = math.floor(math.fmod(randint(), #ColorNames))
local color = ColorNames[r + 1]
-- logger.debug(
-- "|colorbox._policy_shuffle| color:%s, ColorNames:%s (%d), r:%d",
-- vim.inspect(color),
-- vim.inspect(ColorNames),
-- vim.inspect()
-- )
vim.cmd(string.format([[color %s]], color))
end
end

local function _policy()
Expand Down

0 comments on commit 2871108

Please sign in to comment.