1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:40:06 +08:00

feat(todo): add max_len function

This commit is contained in:
wsdjeg 2022-10-21 11:51:17 +08:00
parent 48c818a862
commit 6b989ef361

View File

@ -107,14 +107,23 @@ local function compare_todo(a, b) -- {{{
end
-- }}}
local function max_len(t, k) -- {{{
local l = 0
for _, v in ipairs(t) do
l = math.max(#v[k], l)
end
return l
end
-- }}}
function exit(id, data, event) -- {{{
if id ~= todo_jobid then
return
end
logger.info('todomanager job exit with:' .. data)
table.sort(todos, compare_todo)
local lw = 15
local fw = 50
local lw = max_len(todos, 'label') + 1
local fw = max_len(todos, 'file') + 1
local lines = {}
for _, v in ipairs(todos) do
table.insert(lines,