diff --git a/lua/todo/init.lua b/lua/todo/init.lua index f084837..c126050 100644 --- a/lua/todo/init.lua +++ b/lua/todo/init.lua @@ -7,7 +7,7 @@ local store = require('todo.store') local M = {} ---@type todo.Task[]? -local undo_state = nil +local _undo_state = nil ---@return integer bufnr function M.open() @@ -46,7 +46,7 @@ end ---@param bufnr integer function M._on_write(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) - undo_state = store.active_tasks() + _undo_state = store.active_tasks() diff.apply(lines) buffer.render(bufnr) end @@ -113,8 +113,7 @@ function M.prompt_date() end local due = input ~= '' and input or nil if due then - local y, m, d = due:match('^(%d%d%d%d)-(%d%d)-(%d%d)$') - if not y then + if not due:match('^%d%d%d%d%-%d%d%-%d%d$') then vim.notify('Invalid date format. Use YYYY-MM-DD.', vim.log.levels.ERROR) return end diff --git a/lua/todo/sync/gcal.lua b/lua/todo/sync/gcal.lua index 6565bd6..1406216 100644 --- a/lua/todo/sync/gcal.lua +++ b/lua/todo/sync/gcal.lua @@ -199,7 +199,6 @@ function M.authorize() end local code_verifier = table.concat(verifier) - local sha_result = vim.system({ 'printf', '%s', code_verifier }, { text = true }):wait() local sha_pipe = vim .system({ 'sh', @@ -401,7 +400,14 @@ function M.sync() local extra = task._extra or {} local event_id = extra._gcal_event_id - if (task.status == 'done' or task.status == 'deleted') and event_id then + local should_delete = event_id + and ( + task.status == 'done' + or task.status == 'deleted' + or (task.status == 'pending' and not task.due) + ) + + if should_delete then local del_err = delete_event(access_token, calendar_id, event_id) if not del_err then extra._gcal_event_id = nil @@ -430,18 +436,6 @@ function M.sync() created = created + 1 end end - elseif task.status == 'pending' and not task.due and event_id then - local del_err = delete_event(access_token, calendar_id, event_id) - if not del_err then - extra._gcal_event_id = nil - if next(extra) == nil then - task._extra = nil - else - task._extra = extra - end - task.modified = os.date('!%Y-%m-%dT%H:%M:%SZ') - deleted = deleted + 1 - end end end diff --git a/spec/parse_spec.lua b/spec/parse_spec.lua index a76cf31..f1b2641 100644 --- a/spec/parse_spec.lua +++ b/spec/parse_spec.lua @@ -103,7 +103,7 @@ describe('parse', function() end) it('ignores lowercase prefix', function() - local desc, meta = parse.command_add('hello: world') + local desc, _ = parse.command_add('hello: world') assert.are.equal('hello: world', desc) end)