diff --git a/lua/pending/buffer.lua b/lua/pending/buffer.lua index 5d18e1f..c543c7d 100644 --- a/lua/pending/buffer.lua +++ b/lua/pending/buffer.lua @@ -345,8 +345,25 @@ function M.open_line(above) end local row = vim.api.nvim_win_get_cursor(0)[1] local insert_row = above and (row - 1) or row + local meta_pos = insert_row + 1 + + _rendering = true vim.bo[bufnr].modifiable = true vim.api.nvim_buf_set_lines(bufnr, insert_row, insert_row, false, { '- [ ] ' }) + _rendering = false + + table.insert(_meta, meta_pos, { type = 'task' }) + + local icons = config.get().icons + local total = vim.api.nvim_buf_line_count(bufnr) + for r = meta_pos, math.min(meta_pos + 1, total) do + vim.api.nvim_buf_clear_namespace(bufnr, ns_inline, r - 1, r) + local m = _meta[r] + if m then + apply_inline_row(bufnr, r - 1, m, icons) + end + end + vim.api.nvim_win_set_cursor(0, { insert_row + 1, 6 }) vim.cmd('startinsert!') end