diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/move.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 7c63aa9d7f..144384c294 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1208,6 +1208,24 @@ bool scrolldown(long line_count, int byfold) foldAdjustCursor(); coladvance(curwin->w_curswant); } + + if (curwin->w_cursor.lnum == curwin->w_topline && do_sms) { + // make sure the cursor is in the visible text + validate_virtcol(); + int col = curwin->w_virtcol - curwin->w_skipcol; + int row = 0; + if (col >= width1) { + col -= width1; + ++row; + } + if (col > width2) { + row += col / width2; + col = col % width2; + } + if (row >= curwin->w_height) { + coladvance(curwin->w_virtcol - (row - curwin->w_height + 1) * width2); + } + } return moved; } @@ -1245,7 +1263,7 @@ bool scrollup(long line_count, int byfold) // for a closed fold: go to the last line in the fold (void)hasFolding(lnum, NULL, &lnum); } - if (lnum == curwin->w_topline && curwin->w_p_wrap && curwin->w_p_sms) { + if (lnum == curwin->w_topline && do_sms) { // 'smoothscroll': increase "w_skipcol" until it goes over // the end of the line, then advance to the next line. int add = curwin->w_skipcol > 0 ? width2 : width1; @@ -1310,6 +1328,24 @@ bool scrollup(long line_count, int byfold) coladvance(curwin->w_curswant); } + if (curwin->w_cursor.lnum == curwin->w_topline && do_sms && curwin->w_skipcol > 0) { + // make sure the cursor is in a visible part of the line + validate_virtcol(); + if (curwin->w_virtcol < curwin->w_skipcol + 3) { + int width1 = curwin->w_width - curwin_col_off(); + int width2 = width1 + curwin_col_off2(); + colnr_T col = curwin->w_virtcol; + + if (col < width1) { + col += width1; + } + while (col < curwin->w_skipcol + 3) { + col += width2; + } + coladvance(col); + } + } + bool moved = topline != curwin->w_topline || botline != curwin->w_botline; |