diff options
Diffstat (limited to 'src/move.c')
-rw-r--r-- | src/move.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/move.c b/src/move.c index ac59320cfe..c8a5a23216 100644 --- a/src/move.c +++ b/src/move.c @@ -20,6 +20,7 @@ #include "vim.h" static void comp_botline __ARGS((win_T *wp)); +static int scrolljump_value __ARGS((void)); static int check_top_offset __ARGS((void)); static void curs_rows __ARGS((win_T *wp, int do_botline)); static void validate_botline_win __ARGS((win_T *wp)); @@ -249,7 +250,7 @@ update_topline() scroll_cursor_halfway(FALSE); else { - scroll_cursor_top((int)p_sj, FALSE); + scroll_cursor_top(scrolljump_value(), FALSE); check_botline = TRUE; } } @@ -341,7 +342,7 @@ update_topline() line_count = curwin->w_cursor.lnum - curwin->w_botline + 1 + p_so; if (line_count <= curwin->w_height + 1) - scroll_cursor_bot((int)p_sj, FALSE); + scroll_cursor_bot(scrolljump_value(), FALSE); else scroll_cursor_halfway(FALSE); } @@ -377,6 +378,19 @@ update_topline() } /* + * Return the scrolljump value to use for the current window. + * When 'scrolljump' is positive use it as-is. + * When 'scrolljump' is negative use it as a percentage of the window height. + */ + static int +scrolljump_value() +{ + if (p_sj >= 0) + return (int)p_sj; + return (curwin->w_height * -p_sj) / 100; +} + +/* * Return TRUE when there are not 'scrolloff' lines above the cursor for the * current window. */ |