Skip to content

Commit 407dfc6

Browse files
committed
Adds funcions to check whether item is marked as done or not done
1 parent 7e77b1e commit 407dfc6

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

plugin/vim-todo-lists.vim

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,35 @@ endfunction
114114
function! VimTodoListsToggleItem()
115115
let l:line = getline('.')
116116

117-
if match(l:line, '^\s*\[ \].*') != -1
117+
if VimTodoListsItemIsNotDone(l:line) == 1
118118
call setline('.', substitute(l:line, '^\(\s*\)\[ \]', '\1[X]', ''))
119-
elseif match(l:line, '^\s*\[X\] .*') != -1
119+
elseif VimTodoListsItemIsDone(l:line) == 1
120120
call setline('.', substitute(l:line, '^\(\s*\)\[X\]', '\1[ ]', ''))
121121
endif
122122

123123
endfunction
124124

125125

126+
" Checks that item is not done
127+
function! VimTodoListsItemIsNotDone(line)
128+
if match(a:line, '^\s*\[ \].*') != -1
129+
return 1
130+
else
131+
return 0
132+
endif
133+
endfunction
134+
135+
136+
" Checks that item is done
137+
function! VimTodoListsItemIsDone(line)
138+
if match(a:line, '^\s*\[X\].*') != -1
139+
return 1
140+
else
141+
return 0
142+
endif
143+
endfunction
144+
145+
126146
" Counts the number of leading spaces
127147
function! VimTodoListsCountLeadingSpaces(line)
128148
return (strlen(a:line) - strlen(substitute(a:line, '^\s*', '', '')))

0 commit comments

Comments
 (0)