@@ -153,9 +153,12 @@ endfunction
153153" Moves the item subtree to the specified position
154154function ! VimTodoListsMoveSubtree (lineno, position)
155155 let l: subtree_length = VimTodoListsFindLastChild (a: lineno ) - a: lineno + 1
156+
156157 let l: cursor_pos = getcurpos ()
157158 call cursor (a: lineno , l: cursor_pos [4 ])
158- let l: cursor_pos = getcurpos ()
159+
160+ " Update cursor position
161+ let l: cursor_pos [1 ] = a: lineno
159162
160163 " Copy subtree to the required position
161164 execute ' normal! ' . l: subtree_length . ' Y'
@@ -363,23 +366,24 @@ endfunction
363366" Toggles todo list item
364367function ! VimTodoListsToggleItem ()
365368 let l: line = getline (' .' )
369+ let l: lineno = line (' .' )
366370
367371 " Store current cursor position
368372 let l: cursor_pos = getcurpos ()
369373
370374 if VimTodoListsItemIsNotDone (l: line ) == 1
371- call VimTodoListsForEachChild (line ( ' . ' ) , ' VimTodoListsSetItemDone' )
372- call VimTodoListsMoveSubtreeDown (line ( ' . ' ) )
375+ call VimTodoListsForEachChild (l: lineno , ' VimTodoListsSetItemDone' )
376+ call VimTodoListsMoveSubtreeDown (l: lineno )
373377 elseif VimTodoListsItemIsDone (l: line ) == 1
374- call VimTodoListsForEachChild (line ( ' . ' ) , ' VimTodoListsSetItemNotDone' )
375- call VimTodoListsMoveSubtreeUp (line ( ' . ' ) )
378+ call VimTodoListsForEachChild (l: lineno , ' VimTodoListsSetItemNotDone' )
379+ call VimTodoListsMoveSubtreeUp (l: lineno )
376380 endif
377381
378382 " Restore the current position
379383 " Using the {curswant} value to set the proper column
380384 call cursor (l: cursor_pos [1 ], l: cursor_pos [4 ])
381385
382- call VimTodoListsUpdateParent (line ( ' . ' ) )
386+ call VimTodoListsUpdateParent (l: lineno )
383387endfunction
384388
385389
0 commit comments