Correct a bug in todo#Complete

where the entire lines were being shown as related
This commit is contained in:
fretep
2017-09-24 21:55:45 +10:00
parent 21908548d4
commit f35bcabcea
6 changed files with 53 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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* ~

View File

@@ -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
) $*

View File

@@ -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

View File

@@ -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\<C-X>\<C-O>
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\<C-X>\<C-O>
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+\<C-X>\<C-O>\<ESC>"
:blast!
Expect (Project SecretProject):
Contexts: @Context
Buffers: tests/todo.vader
" file: ftplugin/todo.vim {{{1
" function: TodoFoldLevel(lnum) {{{2