diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-04-26 17:23:42 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-02 13:11:46 +0200 |
commit | d95697d6d4533e84bbb9d262b355ee9f71bd7452 (patch) | |
tree | 26ab574d0d01d7609a6f0533faa6add8168d2afb /src/nvim | |
parent | 3a1973debceca29e65c4f7c83d025cb3314ebaf2 (diff) | |
download | rneovim-d95697d6d4533e84bbb9d262b355ee9f71bd7452.tar.gz rneovim-d95697d6d4533e84bbb9d262b355ee9f71bd7452.tar.bz2 rneovim-d95697d6d4533e84bbb9d262b355ee9f71bd7452.zip |
vim-patch:9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Problem: First line not scrolled properly with 'smoothscroll' and
'scrolloff' zero and using "k".
Solution: Make sure the cursor position is visible.
https://github.com/vim/vim/commit/46b54747c5d252c584571a321231bad9330018ec
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim')
-rw-r--r-- | src/nvim/move.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 0a91b12255..7c63aa9d7f 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -203,7 +203,7 @@ void update_topline(win_T *wp) bool check_topline = false; // If the cursor is above or near the top of the window, scroll the window // to show the line the cursor is in, with 'scrolloff' context. - if (wp->w_topline > 1) { + if (wp->w_topline > 1 || wp->w_skipcol > 0) { // If the cursor is above topline, scrolling is always needed. // If the cursor is far below topline and there is no folding, // scrolling down is never needed. @@ -211,6 +211,15 @@ void update_topline(win_T *wp) check_topline = true; } else if (check_top_offset()) { check_topline = true; + } else if (wp->w_skipcol > 0 && wp->w_cursor.lnum == wp->w_topline) { + colnr_T vcol; + + // check the cursor position is visible. Add 3 for the ">>>" + // displayed in the top-left. + getvvcol(wp, &wp->w_cursor, &vcol, NULL, NULL); + if (wp->w_skipcol + 3 >= vcol) { + check_topline = true; + } } } // Check if there are more filler lines than allowed. @@ -1499,6 +1508,7 @@ void scroll_cursor_top(int min_scroll, int always) linenr_T top; // just above displayed lines linenr_T bot; // just below displayed lines linenr_T old_topline = curwin->w_topline; + int old_skipcol = curwin->w_skipcol; linenr_T old_topfill = curwin->w_topfill; linenr_T new_topline; int off = (int)get_scrolloff_value(curwin); @@ -1588,7 +1598,13 @@ void scroll_cursor_top(int min_scroll, int always) } } check_topfill(curwin, false); + // TODO(vim): if the line doesn't fit may optimize w_skipcol + if (curwin->w_topline == curwin->w_cursor.lnum) { + curwin->w_skipcol = 0; + redraw_later(curwin, UPD_NOT_VALID); + } if (curwin->w_topline != old_topline + || curwin->w_skipcol != old_skipcol || curwin->w_topfill != old_topfill) { curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); |