fix(buffer): correct extmark drift on open_line above/below done tasks
Problem: `open_line` used `nvim_buf_set_lines` which triggered `on_bytes` with a `start_row` offset designed for native `o`/`O` keypresses. The `_meta` entry was inserted one position too late, causing the done task's `PendingDone` highlight to attach to the new blank line instead. Solution: suppress `on_bytes` during `open_line` by reusing the `_rendering` guard, insert the meta entry at the correct position, and immediately reapply inline extmarks for the affected rows.
This commit is contained in:
parent
e643bbebcf
commit
666690ad48
1 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue