Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements, issue fixes #21

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make ^F scroll past EOL
See: #11
  • Loading branch information
subnut committed Oct 31, 2020
commit 2bdd74f74ab0abff94a17262334e753f3b8ea640
17 changes: 17 additions & 0 deletions autoload/smoothie.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let s:ctrl_f_invoked = v:false

if !exists('g:smoothie_update_interval')
""
" Time (in milliseconds) between subseqent screen/cursor postion updates.
Expand Down Expand Up @@ -48,7 +50,15 @@ endfunction
" Scroll the window down by one line, or move the cursor down if the window is
" already at the bottom. Return 1 if cannot move any lower.
function s:step_down()
if !(line('.') < line('$')) && !s:ctrl_f_invoked
" i.e. cursor is at last line of buffer, and movement is not Ctrl-F
" cannot move
return 1
endif
if line('.') < line('$')
if s:ctrl_f_invoked && (winheight(0) - winline()) >= (line('$') - line('.'))
call s:execute_preserving_scroll("normal! \<C-E>")
endif
" NOTE: the three lines of code following this comment block
" have been implemented as a temporary workaround for a vim issue
subnut marked this conversation as resolved.
Show resolved Hide resolved
" regarding Ctrl-D and folds.
Expand All @@ -59,6 +69,9 @@ function s:step_down()
endif
call s:execute_preserving_scroll("normal! 1\<C-D>")
return 0
elseif s:ctrl_f_invoked && winline() > 1
call s:execute_preserving_scroll("normal! \<C-E>")
return 0
else
return 1
endif
Expand Down Expand Up @@ -185,25 +198,29 @@ endfunction
""
" Smooth equivalent to ^D.
function smoothie#downwards()
let s:ctrl_f_invoked = v:false
call s:count_to_scroll()
call s:update_target(&scroll)
endfunction

""
" Smooth equivalent to ^U.
function smoothie#upwards()
let s:ctrl_f_invoked = v:false
call s:count_to_scroll()
call s:update_target(-&scroll)
endfunction

""
" Smooth equivalent to ^F.
function smoothie#forwards()
let s:ctrl_f_invoked = v:true
call s:update_target(winheight(0) * v:count1)
endfunction

""
" Smooth equivalent to ^B.
function smoothie#backwards()
let s:ctrl_f_invoked = v:false
call s:update_target(-winheight(0) * v:count1)
endfunction