mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 17:49:57 +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
|
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) -- {{{
|
function exit(id, data, event) -- {{{
|
||||||
if id ~= todo_jobid then
|
if id ~= todo_jobid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
logger.info('todomanager job exit with:' .. data)
|
logger.info('todomanager job exit with:' .. data)
|
||||||
table.sort(todos, compare_todo)
|
table.sort(todos, compare_todo)
|
||||||
local lw = 15
|
local lw = max_len(todos, 'label') + 1
|
||||||
local fw = 50
|
local fw = max_len(todos, 'file') + 1
|
||||||
local lines = {}
|
local lines = {}
|
||||||
for _, v in ipairs(todos) do
|
for _, v in ipairs(todos) do
|
||||||
table.insert(lines,
|
table.insert(lines,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user