Skip to content

Commit 48b536d

Browse files
committed
Makes the item moving work for simple hierarchy (#13)
1 parent b5cf60f commit 48b536d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugin/vim-todo-lists.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ endfunction
170170
function! VimTodoListsMoveSubtree(lineno, position)
171171
let l:subtree_length = VimTodoListsFindLastChild(a:lineno) - a:lineno + 1
172172
let l:cursor_pos = getcurpos()
173+
call cursor(a:lineno, l:cursor_pos[4])
174+
let l:cursor_pos = getcurpos()
173175

174176
" Copy subtree to the required position
175177
execute 'normal! ' . l:subtree_length . 'Y'
@@ -282,10 +284,14 @@ function! VimTodoListsForEachChild(lineno, function)
282284
return
283285
endif
284286

285-
for current_line in range(a:lineno, l:last_child_lineno)
287+
" Apply the function on children prior to the item.
288+
" This order is required for proper work of the items moving on toggle
289+
for current_line in range(a:lineno + 1, l:last_child_lineno)
286290
call call(a:function, [current_line])
287291
endfor
288292

293+
call call(a:function, [a:lineno])
294+
289295
endfunction
290296

291297

0 commit comments

Comments
 (0)