Skip to content

Commit

Permalink
temporary fix for #12
Browse files Browse the repository at this point in the history
CrunchBlock command calculates using variables incorrectly depending on
cursor position
  • Loading branch information
arecarn committed Sep 10, 2013
1 parent ee2fb97 commit c393ed6
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions autoload/crunch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,37 @@ endfunction
"s:CrunchBlock {{{
" The Top Level Function that determines program flow
"=============================================================================
function! crunch#CrunchBlock() range
let top = a:firstline
let bot = a:lastline
if s:crunch_debug_cb | echo "range: " . top . ", " . bot | endif
if top == bot
" when no range is given (or a sigle line, as it is not possible to
" detect the difference), use the set of lines separed by blank lines
let emptyLinePat = '\v^\s*$'
while top > 1 && getline(top-1) !~ emptyLinePat
let top -= 1
endwhile
while bot < line('$') && getline(bot+1) !~ emptyLinePat
let bot += 1
endwhile
if s:crunch_debug_cb | echo "new range: " . top . ", " . bot | endif
endif
for line in range(top, bot)
call crunch#CrunchLine(line)
endfor
" function! crunch#CrunchBlock() range
" let top = a:firstline
" let bot = a:lastline
" if s:crunch_debug_cb | echo "range: " . top . ", " . bot | endif
" if top == bot
" " when no range is given (or a sigle line, as it is not possible to
" " detect the difference), use the set of lines separed by blank lines
" let emptyLinePat = '\v^\s*$'
" while top > 1 && getline(top-1) !~ emptyLinePat
" let top -= 1
" endwhile
" while bot < line('$') && getline(bot+1) !~ emptyLinePat
" let bot += 1
" endwhile
" if s:crunch_debug_cb | echo "new range: " . top . ", " . bot | endif
" endif
" for line in range(top, bot)
" call crunch#CrunchLine(line)
" endfor
" endfunction

"==========================================================================}}}
"s:CrunchBlock {{{
"Temporary fix for #12: CrunchBlock command calculatesusing tags incorrectly
"depending on cursor position
"=============================================================================
function! crunch#CrunchBlock()
execute "normal! vip\<ESC>"
let topline = line("'<")
let bottomline = line("'>")
execute topline . "," bottomline . "call " . "crunch#CrunchLine('.')"
endfunction

"==========================================================================}}}
Expand Down

0 comments on commit c393ed6

Please sign in to comment.