Created
August 9, 2012 07:11
-
-
Save tobyS/3301871 to your computer and use it in GitHub Desktop.
Fold method calls in Xdebug function traces in VIM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func! FoldCalls(regex) range | |
let l:lastLine = a:lastline | |
let l:firstLine = a:firstline | |
let l:currentSpaceCount = -1 | |
let l:startTime = localtime() | |
let l:currentLine = l:firstLine | |
while l:currentLine <= l:lastLine | |
let l:lineText = getline(l:currentLine) | |
" 1.6975 24568256 -> str_replace(string(1), string(2), string(25)) /h | |
let l:matches = matchlist(l:lineText, '\S\(\s\+\)-> \(.*\)$') | |
if len(l:matches) > 0 | |
let l:whiteSpaceCount = strlen(l:matches[1]) | |
" Continue fold regex matches again | |
if l:whiteSpaceCount <= l:currentSpaceCount && match(l:matches[2], a:regex) == -1 | |
call append(l:currentLine - 1, "}}}") | |
let l:currentLine += 1 | |
let l:lastLine += 1 | |
let l:currentSpaceCount = -1 | |
endif | |
if l:currentSpaceCount == -1 && match(l:matches[2], a:regex) > -1 | |
call append(l:currentLine - 1, "{{{ " . l:matches[2]) | |
let l:currentLine += 1 | |
let l:lastLine += 1 | |
let l:currentSpaceCount = l:whiteSpaceCount | |
endif | |
endif | |
let l:currentLine += 1 | |
endwhile | |
let l:elapsedTime = localtime() - l:startTime | |
echomsg "Elapsed: " . l:elapsedTime | |
endfunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<3
What about folds of descendants using vims folding technique is that already covered by something else?