diff --git a/plugin/todoer.lua b/plugin/todoer.lua index beb2cbe..cd3c14b 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -57,15 +57,15 @@ local function add_todo() local closedpattern = "^%s*%- %[[x]%]" local line = vim.api.nvim_get_current_line() - local i, spaces = string.find(line, "^%s*") + local index, spaces = string.find(line, "^%s*") - if not string.match(line, openpattern) and not string.match(line, closedpattern) then - if i == 1 and spaces == 0 then + if index == 1 and not string.match(line, openpattern) and not string.match(line, closedpattern) then + if index == 1 and spaces == 0 then line = spaces .. "- [ ] " .. line vim.api.nvim_set_current_line(line) - elseif i == 1 and spaces ~= 0 then + elseif index == 1 and spaces > 0 then local spacestring = "" - for x = 1, spaces do + for x = 1, spaces, 1 do spacestring = spacestring .. " " end line = spacestring .. "- [ ] " .. line