Add debug info in hierarchical sort

ADD: Debug info needed for solving issue #5
FIX: Incomplete group detection in hierarchical sort (should not impact
    issue #5)
This commit is contained in:
David Beniamine
2015-12-17 23:23:10 +01:00
parent b6d5dc6bb9
commit 81c2772905

View File

@@ -190,9 +190,17 @@ function! todo#HierarchicalSort(symbol, symbolsub, dolastsort)
" Count the number of lines
let l:position= todo#GetCurpos()
execute "silent normal g\<c-g>"
let l:linecount=str2nr(split(v:statusmsg)[7])
if(exists("g:Todo_txt_debug"))
echo "Linescount: ".l:linecount
endif
" Get all the groups names
let l:groups=GetGroups(a:symbol,1,l:linecount)
if(exists("g:Todo_txt_debug"))
echo "Groups: "
echo l:groups
echo 'execute sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
endif
" Sort by groups
execute 'sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
@@ -225,6 +233,9 @@ function! todo#HierarchicalSort(symbol, symbolsub, dolastsort)
execute l:subgroupBegin.','.l:subgroupEnd.'sort'.l:sortmodefinal
endfor
else
" Sort by priority
if(exists("g:Todo_txt_debug"))
echo 'execute '.l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
endif
execute l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
endif
@@ -239,7 +250,7 @@ function! GetGroups(symbol,begin, end)
function! GetGroups(symbol,begin, end)
let l:curline=a:begin
let l:groups=[]
while l:curline <= a:end
while l:curline <= a:end
let l:curproj=strpart(matchstr(getline(l:curline),a:symbol.'\S*'),1)
if l:curproj != "" && index(l:groups,l:curproj) == -1
let l:groups=add(l:groups , l:curproj)