Skip to content

Commit

Permalink
Use topline instead of winline to fix immobility
Browse files Browse the repository at this point in the history
  • Loading branch information
nkouevda committed Sep 6, 2023
1 parent 31aee09 commit b4ff68a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugin/slash.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function! s:wrap(seq)
endfunction

function! s:immobile(seq)
let s:winline = winline()
let s:topline = winsaveview()['topline']
let s:pos = getpos('.')
return a:seq."\<plug>(slash-prev)"
endfunction
Expand All @@ -42,13 +42,13 @@ function! s:trailer()
augroup END

let seq = foldclosed('.') != -1 ? 'zv' : ''
if exists('s:winline')
let sdiff = winline() - s:winline
unlet s:winline
if exists('s:topline')
let sdiff = winsaveview()['topline'] - s:topline
unlet s:topline
if sdiff > 0
let seq .= sdiff."\<c-e>"
let seq .= sdiff."\<c-y>"
elseif sdiff < 0
let seq .= -sdiff."\<c-y>"
let seq .= -sdiff."\<c-e>"
endif
endif
let after = len(maparg("<plug>(slash-after)", mode())) ? "\<plug>(slash-after)" : ''
Expand Down

0 comments on commit b4ff68a

Please sign in to comment.