Skip to content

Commit

Permalink
ignore moves over folds (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanilaMihailov committed Jun 27, 2020
1 parent b736ed9 commit c30410a
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions plugin/beacon.vim
Expand Up @@ -135,13 +135,32 @@ let s:prev_cursor = 0
" highlight position if cursor moved significally
function! s:Cursor_moved()
let l:cur = line(".")
let l:diff = l:cur - s:prev_cursor
let l:diff = abs(l:cur - s:prev_cursor)

if l:diff > g:beacon_minimal_jump || l:diff < g:beacon_minimal_jump * -1
call s:Highlight_position(v:false)
if l:diff > g:beacon_minimal_jump
let l:prev_fold = foldclosed(s:prev_cursor)
let l:prev_fold_end = foldclosedend(s:prev_cursor)
let l:cur_fold = foldclosed(l:cur)
let l:cur_fold_end = foldclosedend(l:cur)

" if we move over fold, substract fold lines from diff
if l:prev_fold > -1 && l:prev_fold_end > -1
let l:diff -= l:prev_fold_end - l:prev_fold
endif

" if we move over fold, substract fold lines from diff
if l:cur_fold > -1 && l:cur_fold_end > -1
let l:diff -= l:cur_fold_end - l:cur_fold
endif

" check diff again before highlight
if l:diff > g:beacon_minimal_jump
call s:Highlight_position(v:false)
endif
endif

let s:prev_cursor = l:cur

endfunction

function! s:Beacon_toggle() abort
Expand Down

0 comments on commit c30410a

Please sign in to comment.