Skip to content

Commit

Permalink
Check for a non-empty table before using math.max(unpack(...)) (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbthomason committed Dec 14, 2020
1 parent 7ffe133 commit ccfb54c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/packer/plugin_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ plugin_utils.helptags_stale = function(dir)
vim.list_extend(txts, vim.fn.glob(util.join_paths(dir, '*.[a-z][a-z]x'), true, true))
local tags = vim.fn.glob(util.join_paths(dir, 'tags'), true, true)
vim.list_extend(tags, vim.fn.glob(util.join_paths(dir, 'tags-[a-z][a-z]'), true, true))
local txt_newest = math.max(unpack(util.map(vim.fn.getftime, txts)))
local tag_oldest = math.min(unpack(util.map(vim.fn.getftime, tags)))
local txt_ftimes = util.map(vim.fn.getftime, txts)
local tag_ftimes = util.map(vim.fn.getftime, tags)
if #txt_ftimes == 0 or #tag_ftimes == 0 then
return false
end

local txt_newest = math.max(unpack(txt_ftimes))
local tag_oldest = math.min(unpack(tag_ftimes))
return txt_newest > tag_oldest
end

Expand Down

0 comments on commit ccfb54c

Please sign in to comment.