diff options
Diffstat (limited to 'src/nvim/move.c')
-rw-r--r-- | src/nvim/move.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 4c1b8a8411..134ffcd7dc 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1,3 +1,6 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + /* * move.c: Functions for moving the cursor and scrolling text. * @@ -1760,7 +1763,7 @@ int onepage(int dir, long count) loff.fill = 0; if (dir == FORWARD) { - if (firstwin == lastwin && p_window > 0 && p_window < Rows - 1) { + if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) { /* Vi compatible scrolling */ if (p_window <= 2) ++curwin->w_topline; @@ -1794,7 +1797,7 @@ int onepage(int dir, long count) max_topfill(); continue; } - if (firstwin == lastwin && p_window > 0 && p_window < Rows - 1) { + if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) { /* Vi compatible scrolling (sort of) */ if (p_window <= 2) --curwin->w_topline; @@ -1878,8 +1881,10 @@ int onepage(int dir, long count) } foldAdjustCursor(); cursor_correct(); - if (retval == OK) + check_cursor_col(); + if (retval == OK) { beginline(BL_SOL | BL_FIX); + } curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL); /* @@ -1984,9 +1989,8 @@ void halfpage(bool flag, linenr_T Prenum) while (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count) { if (curwin->w_topfill > 0) { i = 1; - if (--n < 0 && scrolled > 0) - break; - --curwin->w_topfill; + n--; + curwin->w_topfill--; } else { i = plines_nofill(curwin->w_topline); n -= i; @@ -2062,9 +2066,8 @@ void halfpage(bool flag, linenr_T Prenum) while (n > 0 && curwin->w_topline > 1) { if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)) { i = 1; - if (--n < 0 && scrolled > 0) - break; - ++curwin->w_topfill; + n--; + curwin->w_topfill++; } else { i = plines_nofill(curwin->w_topline - 1); n -= i; @@ -2142,14 +2145,12 @@ void do_check_cursorbind(void) curbuf = curwin->w_buffer; /* skip original window and windows with 'noscrollbind' */ if (curwin != old_curwin && curwin->w_p_crb) { - if (curwin->w_p_diff) - curwin->w_cursor.lnum - = diff_get_corresponding_line(old_curbuf, - line, - curbuf, - curwin->w_cursor.lnum); - else + if (curwin->w_p_diff) { + curwin->w_cursor.lnum = + diff_get_corresponding_line(old_curbuf, line); + } else { curwin->w_cursor.lnum = line; + } curwin->w_cursor.col = col; curwin->w_cursor.coladd = coladd; curwin->w_curswant = curswant; @@ -2161,16 +2162,21 @@ void do_check_cursorbind(void) int restart_edit_save = restart_edit; restart_edit = true; check_cursor(); + if (curwin->w_p_cul || curwin->w_p_cuc) { + validate_cursor(); + } restart_edit = restart_edit_save; } - /* Correct cursor for multi-byte character. */ - if (has_mbyte) + // Correct cursor for multi-byte character. + if (has_mbyte) { mb_adjust_cursor(); + } redraw_later(VALID); - /* Only scroll when 'scrollbind' hasn't done this. */ - if (!curwin->w_p_scb) + // Only scroll when 'scrollbind' hasn't done this. + if (!curwin->w_p_scb) { update_topline(); + } curwin->w_redr_status = true; } } |