aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-18 06:13:46 +0800
committerGitHub <noreply@github.com>2024-05-18 06:13:46 +0800
commit5f9e7edae6b8d56dd44b41dee02b8e9411572b58 (patch)
treeb1a9c756bfe8999cf429f3d07d3d03cce67056b4 /src
parent512d228111bccf3e52613c798edc7f803c1de13f (diff)
parentf178b8ba4963345879c3a1291ab81805d17c2e0e (diff)
downloadrneovim-5f9e7edae6b8d56dd44b41dee02b8e9411572b58.tar.gz
rneovim-5f9e7edae6b8d56dd44b41dee02b8e9411572b58.tar.bz2
rneovim-5f9e7edae6b8d56dd44b41dee02b8e9411572b58.zip
Merge pull request #28790 from luukvbaal/vim-9.1.0414
vim-patch:9.1.{0414,0416}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/move.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index ef4346da76..074eb0354c 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1579,8 +1579,20 @@ void adjust_skipcol(void)
redraw_later(curwin, UPD_NOT_VALID);
return; // don't scroll in the other direction now
}
- colnr_T col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols;
int row = 0;
+ colnr_T col = curwin->w_virtcol + scrolloff_cols;
+
+ // Avoid adjusting for 'scrolloff' beyond the text line height.
+ if (scrolloff_cols > 0) {
+ int size = win_linetabsize(curwin, curwin->w_topline,
+ ml_get(curwin->w_topline), (colnr_T)MAXCOL);
+ size = width1 + width2 * ((size - width1 + width2 - 1) / width2);
+ while (col > size) {
+ col -= width2;
+ }
+ }
+ col -= curwin->w_skipcol;
+
if (col >= width1) {
col -= width1;
row++;
@@ -2114,7 +2126,10 @@ void scroll_cursor_bot(win_T *wp, int min_scroll, bool set_topbot)
wp->w_valid |= VALID_TOPLINE;
wp->w_viewport_invalid = true;
- cursor_correct_sms(wp);
+ // Make sure cursor is still visible after adjusting skipcol for "zb".
+ if (set_topbot) {
+ cursor_correct_sms(wp);
+ }
}
/// Recompute topline to put the cursor halfway across the window