mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:10:04 +08:00
feat(todo): add max_len function
This commit is contained in:
parent
48c818a862
commit
6b989ef361
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user