diff --git a/README.markdown b/README.markdown index 9b2ec1f..fe387b8 100644 --- a/README.markdown +++ b/README.markdown @@ -173,6 +173,12 @@ buffers in which they appears in the preview window. It does the same thing for context except that it gives in the preview the list of projects existing in each existing contexts. +If you don't want the preview window to open when performing completion, add the +following lines to your vimrc: + + au filetype todo setlocal completeopt-=preview + + ## Hierarchical sort This fork provides a hierarchical sorting function designed to do by project diff --git a/autoload/todo.vim b/autoload/todo.vim index 2842844..e694c17 100644 --- a/autoload/todo.vim +++ b/autoload/todo.vim @@ -393,7 +393,11 @@ endfun fun! TodoCopyTempItem(item) let ret={} let ret.word=a:item.word - let ret.related=[a:item.related] + if has_key(a:item, "related") + let ret.related=[a:item.related] + else + let ret.related=[] + endif let ret.buffers=[a:item.buffers] return ret endfun @@ -423,7 +427,9 @@ fun! todo#Complete(findstart, base) let item={} let item.word=substitute(line,'.*\('.a:base.'\S*\).*','\1',"") let item.buffers=bufname(bufnr) - let item.related=substitute(line,'.*\s\('.opp.'\S\S*\).*','\1',"") + if line =~ '.*\s\('.opp.'\S\S*\).*' + let item.related=substitute(line,'.*\s\('.opp.'\S\S*\).*','\1',"") + endif call add(res,item) endif endfor @@ -436,7 +442,7 @@ fun! todo#Complete(findstart, base) for it in res if curitem.word==it.word " Merge results - if index(curitem.related,it.related) <0 + if has_key(curitem, "related") && has_key(it, "related") && index(curitem.related,it.related) <0 call add(curitem.related,it.related) endif if index(curitem.buffers,it.buffers) <0 diff --git a/doc/todo.txt b/doc/todo.txt index 087c25f..51851db 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -182,6 +182,12 @@ buffers in which they appears in the preview window. It does the same thing for context except that it gives in the preview the list of projects existing in each existing contexts. +If you don't want the preview window to open when performing completion, add the +following lines to your vimrc: +> + au filetype todo setlocal completeopt-=preview +< + =============================================================================== 5. Hierarchical sort *TodoTxt-HierarchicalSort* ~ diff --git a/tests/clean-vim.sh b/tests/clean-vim.sh index 6960d75..8838151 100644 --- a/tests/clean-vim.sh +++ b/tests/clean-vim.sh @@ -11,6 +11,7 @@ set rtp+=~/.vim/bundle/vader.vim set rtp+=./ filetype plugin indent on syntax enable +autocmd filetype todo setlocal omnifunc=todo#Complete EOF -) tests/todo.txt +) $* diff --git a/tests/runtests.sh b/tests/runtests.sh index d4902b4..5774bfa 100644 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -11,6 +11,7 @@ set rtp+=~/.vim/bundle/vader.vim set rtp+=./ filetype plugin indent on syntax enable +autocmd filetype todo setlocal omnifunc=todo#Complete EOF ) +Vader! tests/*.vader && echo Success || exit 1 @@ -24,6 +25,7 @@ set rtp+=~/.vim/bundle/vader.vim set rtp+=./ filetype plugin indent on syntax enable +autocmd filetype todo setlocal omnifunc=todo#Complete set ignorecase EOF ) +Vader! tests/*.vader && echo Success || exit 1 @@ -37,6 +39,7 @@ set rtp+=~/.vim/bundle/vader.vim set rtp+=./ filetype plugin indent on syntax enable +autocmd filetype todo setlocal omnifunc=todo#Complete set iskeyword+=- EOF ) +Vader! tests/*.vader && echo Success || exit 1 diff --git a/tests/todo.vader b/tests/todo.vader index 65f32e9..b70647d 100644 --- a/tests/todo.vader +++ b/tests/todo.vader @@ -760,6 +760,33 @@ Then (Is cursor on first non-overdue task?): After: unlet g:TodoTxtSortDueDateCursorPos +" function todo#Complete(findstart, base) {{{2 +Given todo (Tasks): + 2017-09-23 Test task +SecretProject @Work due:2017-09-26 + Tricky lowercase @wrongCaseSelected +selectedWrongCase + Project without a context +SecretProject +Do (Complete context W): + Go@W\\ +Expect todo (Context Work): + 2017-09-23 Test task +SecretProject @Work due:2017-09-26 + Tricky lowercase @wrongCaseSelected +selectedWrongCase + Project without a context +SecretProject + @Work +Do (Complete project S): + Go+S\\ +Expect todo (Project SecretProject): + 2017-09-23 Test task +SecretProject @Work due:2017-09-26 + Tricky lowercase @wrongCaseSelected +selectedWrongCase + Project without a context +SecretProject + +SecretProject +Execute (Complete project and switch to preview): + :execute "normal Go+\\\" + :blast! +Expect (Project SecretProject): + Contexts: @Context + Buffers: tests/todo.vader + + " file: ftplugin/todo.vim {{{1 " function: TodoFoldLevel(lnum) {{{2