summaryrefslogtreecommitdiff
path: root/src/move.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-09 17:19:27 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-09 17:19:27 +0100
commit118c235112854f34182d968613d7fe98be3b290b (patch)
tree6fdf02b382317c4fb685ca77939212b4b61a4180 /src/move.c
parent28f7e701b7857cfc5ab5531ee7ac26e2542ad662 (diff)
downloadvim-git-118c235112854f34182d968613d7fe98be3b290b.tar.gz
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long linev9.0.0707
Problem: With 'smoothscroll' and 'scrolloff' non-zero the cursor position is not properly adjusted in a long line. Solution: Move the cursor further up or down in the line.
Diffstat (limited to 'src/move.c')
-rw-r--r--src/move.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/move.c b/src/move.c
index 613791e3e..32cd6f37e 100644
--- a/src/move.c
+++ b/src/move.c
@@ -1605,9 +1605,12 @@ scrolldown(
if (curwin->w_cursor.lnum == curwin->w_topline && do_sms)
{
+ long so = curwin->w_p_so >= 0 ? curwin->w_p_so : p_so;
+ int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
+
// make sure the cursor is in the visible text
validate_virtcol();
- int col = curwin->w_virtcol - curwin->w_skipcol;
+ int col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols;
int row = 0;
if (col >= width1)
{
@@ -1620,8 +1623,11 @@ scrolldown(
col = col % width2;
}
if (row >= curwin->w_height)
- coladvance(curwin->w_virtcol
- - (row - curwin->w_height + 1) * width2);
+ {
+ curwin->w_curswant = curwin->w_virtcol
+ - (row - curwin->w_height + 1) * width2;
+ coladvance(curwin->w_curswant);
+ }
}
}
@@ -1748,19 +1754,24 @@ scrollup(
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
+ int width1 = curwin->w_width - curwin_col_off();
+ int width2 = width1 + curwin_col_off2();
+ long so = curwin->w_p_so >= 0 ? curwin->w_p_so : p_so;
+ int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
+
+ // Make sure the cursor is in a visible part of the line, taking
+ // 'scrolloff' into account, but using screen lines.
validate_virtcol();
- if (curwin->w_virtcol < curwin->w_skipcol + 3)
+ if (curwin->w_virtcol < curwin->w_skipcol + 3 + scrolloff_cols)
{
- 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)
+ while (col < curwin->w_skipcol + 3 + scrolloff_cols)
col += width2;
- coladvance(col);
+ curwin->w_curswant = col;
+ coladvance(curwin->w_curswant);
}
}
}