From 48c818a86224fd9b061092509db8706b5ae9f6bc Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 20 Oct 2022 23:03:53 +0800 Subject: [PATCH] fix(todo): fix todo manager sort function --- lua/spacevim/plugin/todo.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/spacevim/plugin/todo.lua b/lua/spacevim/plugin/todo.lua index 1deab57ee..c642c39e8 100644 --- a/lua/spacevim/plugin/todo.lua +++ b/lua/spacevim/plugin/todo.lua @@ -57,7 +57,7 @@ local function stdout(id, data, event) -- {{{ local i, j = string.find(d, ':%d+:') local line = string.sub(d, i + 1, j - 1) local column = string.sub(vim.fn.matchstr(d, [[\(:\d\+\)\@<=:\d\+:]]), 1, -2) - local label = vim.fn.matchstr(d, labels_partten) + local label = string.sub(vim.fn.matchstr(d, labels_partten), #prefix + 1, -1) local title = vim.fn.get(vim.fn.split(d, label), 1, '') table.insert(todos, { file = f, @@ -85,8 +85,8 @@ local function indexof(t, v) -- {{{ if x == v then return i end - return -1 end + return -1 end -- }}} @@ -96,10 +96,9 @@ local function extend(t1, t2) -- {{{ end end -- }}} - local function compare_todo(a, b) -- {{{ - local i = indexof(labels, a) - local j = indexof(labels, b) + local i = indexof(labels, a.label) + local j = indexof(labels, b.label) if i < j then return true else @@ -119,7 +118,7 @@ function exit(id, data, event) -- {{{ local lines = {} for _, v in ipairs(todos) do table.insert(lines, - v.label .. string.rep(' ', lw - #v.label) .. v.file .. string.rep(' ', fw - #v.file) .. v.title + prefix .. v.label .. string.rep(' ', lw - #v.label) .. v.file .. string.rep(' ', fw - #v.file) .. v.title ) end local ma = vim.fn.getbufvar(bufnr, '&ma')