fix(init): reposition cursor after priority toggle re-render
Problem: pressing ! re-sorts the view so the toggled task moves to the top of its category, but the cursor stays on the original line number and lands on a different task. Solution: after buffer.render(), iterate buffer.meta() to find the new line number for the toggled task's id and call nvim_win_set_cursor to follow it.
This commit is contained in:
parent
6b14a6bf90
commit
d2c9eb1808
1 changed files with 6 additions and 0 deletions
|
|
@ -135,6 +135,12 @@ function M.toggle_priority()
|
||||||
store.update(id, { priority = new_priority })
|
store.update(id, { priority = new_priority })
|
||||||
store.save()
|
store.save()
|
||||||
buffer.render(bufnr)
|
buffer.render(bufnr)
|
||||||
|
for lnum, m in ipairs(buffer.meta()) do
|
||||||
|
if m.id == id then
|
||||||
|
vim.api.nvim_win_set_cursor(0, { lnum, 0 })
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.prompt_date()
|
function M.prompt_date()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue