Skip to content

Commit e83766c

Browse files
committed
Code refactoring (#13)
1 parent e6d2627 commit e83766c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

plugin/vim-todo-lists.vim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,12 @@ endfunction
153153
" Moves the item subtree to the specified position
154154
function! 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
364367
function! 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)
383387
endfunction
384388

385389

0 commit comments

Comments
 (0)