diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index 8eb68fb..79c6c39 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -108,18 +108,17 @@ setlocal foldtext=TodoFoldText() " Go to first completed task let oldpos=getcurpos() -let g:Todo_fold_char='@' -let base_pos=search('^x\s', 'ce') -" Get next completed task -let first_incomplete = search('^\s*[^]') -if (first_incomplete < base_pos) - " Check if all tasks from - let g:Todo_fold_char='x' -else - " TODO detect if sorted on prjects +if(!exists("g:Todo_fold_char")) let g:Todo_fold_char='@' + let base_pos=search('^x\s', 'ce') + " Get next completed task + let first_incomplete = search('^\s*[^]') + if (first_incomplete < base_pos) + " Check if all tasks from + let g:Todo_fold_char='x' + endif + call setpos('.', oldpos) endif -call setpos('.', oldpos) function! s:get_contextproject(line) abort "{{{2 return matchstr(getline(a:line), g:Todo_fold_char.'[^ ]\+') @@ -156,7 +155,7 @@ function! TodoFoldText() " where N is the number of lines folded. return '+' . v:folddashes . ' ' \ . (v:foldend - v:foldstart + 1) - \ .' '. this_context + \ .' '. this_context.' ' endfunction " Restore context {{{1 diff --git a/tests/include/setup.vader b/tests/include/setup.vader index 8524cb5..ca4a201 100644 --- a/tests/include/setup.vader +++ b/tests/include/setup.vader @@ -15,6 +15,7 @@ Execute (Clean up test environment): execute "silent! %substitute/" . s:duedate . "/**TODAY+2" . b:unit . "**/" endfor endfunction + let g:Todo_fold_char='x' Before: After: