Skip to content

Commit

Permalink
Improve the stability of cursor motions
Browse files Browse the repository at this point in the history
They are very delicate, treat them well :D
  • Loading branch information
subnut committed Nov 17, 2020
1 parent ceb2cef commit 76f382f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions autoload/smoothie.vim
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ function s:update_target(lines)
if g:smoothie_break_on_reverse && s:target_displacement * a:lines < 0
call s:stop_moving()
else
" Cursor movements are very delicate. Since the displacement for cursor
" movements is calulated from the "current" line, so immediately stop
" moving, otherwise we will end up at the wrong line.
if s:cursor_movement
call s:stop_moving()
endif
let s:target_displacement += a:lines
call s:start_moving()
endif
Expand Down Expand Up @@ -331,7 +337,7 @@ function smoothie#gg()
let s:cursor_movement = v:false
" :help 'startofline'
if &startofline
call cursor(line('.'), 1)
call cursor(line('.'), match(getline('.'),'\S')+1)
endif
endfunction

Expand Down Expand Up @@ -361,7 +367,7 @@ function smoothie#G()
let s:cursor_movement = v:false
" :help 'startofline'
if &startofline
call cursor(line('.'), 1)
call cursor(line('.'), match(getline('.'),'\S')+1)
endif
endfunction

Expand Down

0 comments on commit 76f382f

Please sign in to comment.