aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2023-05-14 00:03:03 +0200
committerGitHub <noreply@github.com>2023-05-14 06:03:03 +0800
commitedfa8d6f2f2bc87f3d98b26ef3f8afbfdc8c5bde (patch)
tree0adceb7c7008945515f5d254db6ad579314eb92d /src
parent08991b078267e5de0a19a136d00d4f71ad651a32 (diff)
downloadrneovim-edfa8d6f2f2bc87f3d98b26ef3f8afbfdc8c5bde.tar.gz
rneovim-edfa8d6f2f2bc87f3d98b26ef3f8afbfdc8c5bde.tar.bz2
rneovim-edfa8d6f2f2bc87f3d98b26ef3f8afbfdc8c5bde.zip
vim-patch:9.0.1551: position of marker for 'smoothscroll' not computed correctly (#23617)
Problem: Position of marker for 'smoothscroll' not computed correctly. Solution: Take 'list' and other options into account. (Luuk van Baal, closes vim/vim#12393) https://github.com/vim/vim/commit/24b62ec8258cc7c9ca2c09f645f7f6b02584c892
Diffstat (limited to 'src')
-rw-r--r--src/nvim/change.c3
-rw-r--r--src/nvim/move.c35
2 files changed, 22 insertions, 16 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c
index a9e7126afc..f4969d0ca9 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -257,7 +257,8 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, linenr_T
|| (wp->w_topline >= lnum
&& wp->w_topline < lnume
&& win_linetabsize(wp, wp->w_topline, ml_get(wp->w_topline), (colnr_T)MAXCOL)
- <= (unsigned)wp->w_skipcol + (wp->w_p_list && wp->w_p_lcs_chars.prec ? 1 : 3)))) {
+ <= (unsigned)(wp->w_skipcol + sms_marker_overlap(wp, win_col_off(wp)
+ - win_col_off2(wp)))))) {
wp->w_skipcol = 0;
}
diff --git a/src/nvim/move.c b/src/nvim/move.c
index ada6d004e8..6a6f8149dd 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -164,19 +164,25 @@ static void redraw_for_cursorcolumn(win_T *wp)
}
}
-/// Calculates how much overlap the smoothscroll marker "<<<" overlaps with
-/// buffer text for curwin.
+/// Calculates how much the 'listchars' "precedes" or 'smoothscroll' "<<<"
+/// marker overlaps with buffer text for window "wp".
/// Parameter "extra2" should be the padding on the 2nd line, not the first
/// line.
/// Returns the number of columns of overlap with buffer text, excluding the
/// extra padding on the ledge.
-static int smoothscroll_marker_overlap(win_T *wp, int extra2)
+int sms_marker_overlap(win_T *wp, int extra2)
{
- // We don't draw the <<< marker when in showbreak mode, thus no need to
+ // There is no marker overlap when in showbreak mode, thus no need to
// account for it. See grid_put_linebuf().
if (*get_showbreak_value(wp) != NUL) {
return 0;
}
+
+ // Overlap when 'list' and 'listchars' "precedes" are set is 1.
+ if (wp->w_p_list && wp->w_p_lcs_chars.prec) {
+ return 1;
+ }
+
return extra2 > 3 ? 0 : 3 - extra2;
}
@@ -270,12 +276,11 @@ void update_topline(win_T *wp)
} else if (wp->w_skipcol > 0 && wp->w_cursor.lnum == wp->w_topline) {
colnr_T vcol;
- // Check that the cursor position is visible. Add columns for the
- // smoothscroll marker "<<<" displayed in the top-left if needed.
+ // Check that the cursor position is visible. Add columns for
+ // the marker displayed in the top-left if needed.
getvvcol(wp, &wp->w_cursor, &vcol, NULL, NULL);
- int smoothscroll_overlap = smoothscroll_marker_overlap(wp,
- win_col_off(wp) - win_col_off2(wp));
- if (wp->w_skipcol + smoothscroll_overlap > vcol) {
+ int overlap = sms_marker_overlap(wp, win_col_off(wp) - win_col_off2(wp));
+ if (wp->w_skipcol + overlap > vcol) {
check_topline = true;
}
}
@@ -1426,10 +1431,9 @@ bool scrollup(long line_count, int byfold)
long scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
int space_cols = (curwin->w_height_inner - 1) * width2;
- // If we have non-zero scrolloff, just ignore the <<< marker as we are
+ // If we have non-zero scrolloff, just ignore the marker as we are
// going past it anyway.
- int smoothscroll_overlap = scrolloff_cols != 0 ? 0 :
- smoothscroll_marker_overlap(curwin, extra2);
+ int overlap = scrolloff_cols != 0 ? 0 : sms_marker_overlap(curwin, extra2);
// Make sure the cursor is in a visible part of the line, taking
// 'scrolloff' into account, but using screen lines.
@@ -1438,13 +1442,13 @@ bool scrollup(long line_count, int byfold)
scrolloff_cols = space_cols / 2;
}
validate_virtcol();
- if (curwin->w_virtcol < curwin->w_skipcol + smoothscroll_overlap + scrolloff_cols) {
+ if (curwin->w_virtcol < curwin->w_skipcol + overlap + scrolloff_cols) {
colnr_T col = curwin->w_virtcol;
if (col < width1) {
col += width1;
}
- while (col < curwin->w_skipcol + smoothscroll_overlap + scrolloff_cols) {
+ while (col < curwin->w_skipcol + overlap + scrolloff_cols) {
col += width2;
}
curwin->w_curswant = col;
@@ -1489,8 +1493,9 @@ void adjust_skipcol(void)
}
validate_virtcol();
+ int overlap = sms_marker_overlap(curwin, curwin_col_off() - curwin_col_off2());
while (curwin->w_skipcol > 0
- && curwin->w_virtcol < curwin->w_skipcol + 3 + scrolloff_cols) {
+ && curwin->w_virtcol < curwin->w_skipcol + overlap + scrolloff_cols) {
// scroll a screen line down
if (curwin->w_skipcol >= width1 + width2) {
curwin->w_skipcol -= width2;