fix(buffer): keep _meta in sync when open_line inserts a new line

Problem: `open_line` inserted a buffer line without updating `_meta`,
leaving the entry at that row pointing to the task that was shifted
down. Pressing `<CR>` (toggle_complete) would read the stale meta,
find a real task ID, toggle it, and re-render — destroying the unsaved
new line.

Solution: Insert a `{ type = 'blank' }` sentinel into `_meta` at the
new line's position so buffer-local actions see no task there.
This commit is contained in:
Barrett Ruth 2026-03-06 11:40:11 -05:00
parent 90f85ba098
commit 133369b968

View file

@ -133,6 +133,7 @@ function M.open_line(above)
local insert_row = above and (row - 1) or row
vim.bo[bufnr].modifiable = true
vim.api.nvim_buf_set_lines(bufnr, insert_row, insert_row, false, { '- [ ] ' })
table.insert(_meta, insert_row + 1, { type = 'blank' })
vim.api.nvim_win_set_cursor(0, { insert_row + 1, 6 })
vim.cmd('startinsert!')
end