Skip to content

Commit

Permalink
Extract function for calculating visual lines
Browse files Browse the repository at this point in the history
  • Loading branch information
bobwhitelock committed Aug 6, 2016
1 parent 4a6e22e commit 34f41c1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions plugin/visual-split.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@ function! s:lines_between(line1, line2)
if &wrap
" Calculate the number of visibly selected lines, which may be more
" than the number of actual selected lines.
call cursor(a:line1, 0)
let l:visual_lines = 0
while line('.') <= a:line2
normal! gj
let l:visual_lines += 1
endwhile
return l:visual_lines
return s:visual_lines_between(a:line1, a:line2)
else
" The number of selected lines is a simple calculation.
return a:line2 - a:line1 + 1
endif
endfunction

function! s:visual_lines_between(line1, line2)
call cursor(a:line1, 0)
let l:visual_lines = 0
while line('.') <= a:line2
normal! gj
let l:visual_lines += 1
endwhile
return l:visual_lines
endfunction

function! s:scroll(line)
let scrolloff = &scrolloff
let &scrolloff = 0
Expand Down

0 comments on commit 34f41c1

Please sign in to comment.