Patch 9.0.1551
Problem: Position of marker for 'smoothscroll' not computed correctly.
Solution: Take 'list' and other options into account. (Luuk van Baal,
closes #12393)
Files: src/change.c, src/move.c, src/proto/move.pro,
src/testdir/test_scroll_opt.vim
*** ../vim-9.0.1550/src/change.c 2023-05-11 19:23:49.213031292 +0100
--- src/change.c 2023-05-13 14:08:21.782232852 +0100
***************
*** 568,575 ****
&& wp->w_topline < lnume
&& win_linetabsize(wp, wp->w_topline,
ml_get(wp->w_topline), (colnr_T)MAXCOL)
! <= wp->w_skipcol + (wp->w_p_list
! && wp->w_lcs_chars.prec ? 1 : 3))))
wp->w_skipcol = 0;
// Check if a change in the buffer has invalidated the cached
--- 568,575 ----
&& wp->w_topline < lnume
&& win_linetabsize(wp, wp->w_topline,
ml_get(wp->w_topline), (colnr_T)MAXCOL)
! <= wp->w_skipcol + sms_marker_overlap(wp,
! win_col_off(wp) - win_col_off2(wp)))))
wp->w_skipcol = 0;
// Check if a change in the buffer has invalidated the cached
*** ../vim-9.0.1550/src/move.c 2023-05-11 18:37:57.441591098 +0100
--- src/move.c 2023-05-13 14:09:06.134267312 +0100
***************
*** 202,223 ****
#endif
/*
! * Calculates how much overlap the smoothscroll marker "<<<" overlaps with
! * buffer text for curwin.
* 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(int extra2)
{
#if defined(FEAT_LINEBREAK)
! // We don't draw the <<< marker when in showbreak mode, thus no need to
// account for it. See wlv_screen_line().
! if (*get_showbreak_value(curwin) != NUL)
return 0;
#endif
return extra2 > 3 ? 0 : 3 - extra2;
}
--- 202,227 ----
#endif
/*
! * 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.
*/
! int
! sms_marker_overlap(win_T *wp, int extra2)
{
#if defined(FEAT_LINEBREAK)
! // There is no marker overlap when in showbreak mode, thus no need to
// account for it. See wlv_screen_line().
! if (*get_showbreak_value(wp) != NUL)
return 0;
#endif
+ // Overlap when 'list' and 'listchars' "precedes" are set is 1.
+ if (wp->w_p_list && wp->w_lcs_chars.prec)
+ return 1;
+
return extra2 > 3 ? 0 : 3 - extra2;
}
***************
*** 346,357 ****
colnr_T vcol;
// Check that the cursor position is visible. Add columns for
! // the smoothscroll marker "<<<" displayed in the top-left if
! // needed.
getvvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
! int smoothscroll_overlap = smoothscroll_marker_overlap(
! curwin_col_off() - curwin_col_off2());
! if (curwin->w_skipcol + smoothscroll_overlap > vcol)
check_topline = TRUE;
}
}
--- 350,360 ----
colnr_T vcol;
// Check that the cursor position is visible. Add columns for
! // the marker displayed in the top-left if needed.
getvvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
! int overlap = sms_marker_overlap(curwin, curwin_col_off()
! - curwin_col_off2());
! if (curwin->w_skipcol + overlap > vcol)
check_topline = TRUE;
}
}
***************
*** 1883,1892 ****
int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
int space_cols = (curwin->w_height - 1) * width2;
! // 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(extra2);
// Make sure the cursor is in a visible part of the line, taking
// 'scrolloff' into account, but using screen lines.
--- 1886,1895 ----
int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
int space_cols = (curwin->w_height - 1) * width2;
! // If we have non-zero scrolloff, just ignore the marker as we are
// going past it anyway.
! 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.
***************
*** 1894,1908 ****
if (scrolloff_cols > space_cols / 2)
scrolloff_cols = space_cols / 2;
validate_virtcol();
! if (curwin->w_virtcol < curwin->w_skipcol
! + smoothscroll_overlap + scrolloff_cols)
{
colnr_T col = curwin->w_virtcol;
if (col < width1)
col += width1;
! while (col < curwin->w_skipcol
! + smoothscroll_overlap + scrolloff_cols)
col += width2;
curwin->w_curswant = col;
coladvance(curwin->w_curswant);
--- 1897,1909 ----
if (scrolloff_cols > space_cols / 2)
scrolloff_cols = space_cols / 2;
validate_virtcol();
! 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 + overlap + scrolloff_cols)
col += width2;
curwin->w_curswant = col;
coladvance(curwin->w_curswant);
***************
*** 1949,1956 ****
}
validate_virtcol();
while (curwin->w_skipcol > 0
! && curwin->w_virtcol < curwin->w_skipcol + 3 + scrolloff_cols)
{
// scroll a screen line down
if (curwin->w_skipcol >= width1 + width2)
--- 1950,1959 ----
}
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 + overlap + scrolloff_cols)
{
// scroll a screen line down
if (curwin->w_skipcol >= width1 + width2)
*** ../vim-9.0.1550/src/proto/move.pro 2023-05-06 12:39:58.736971487 +0100
--- src/proto/move.pro 2023-05-13 14:09:24.174280501 +0100
***************
*** 1,6 ****
--- 1,7 ----
/* move.c */
int adjust_plines_for_skipcol(win_T *wp, int n);
void redraw_for_cursorline(win_T *wp);
+ int sms_marker_overlap(win_T *wp, int extra2);
void update_topline_redraw(void);
void update_topline(void);
void update_curswant_force(void);
*** ../vim-9.0.1550/src/testdir/test_scroll_opt.vim 2023-05-12
15:47:21.860773278 +0100
--- src/testdir/test_scroll_opt.vim 2023-05-13 14:05:27.406063560 +0100
***************
*** 426,433 ****
" Test moving the cursor behind the <<< display with 'virtualedit'
set virtualedit=all
! exe "normal \<C-E>"
! norm 3lgkh
call s:check_col_calc(3, 2, 23)
set virtualedit&
--- 426,432 ----
" Test moving the cursor behind the <<< display with 'virtualedit'
set virtualedit=all
! exe "normal \<C-E>3lgkh"
call s:check_col_calc(3, 2, 23)
set virtualedit&
***************
*** 499,504 ****
--- 498,513 ----
call s:check_col_calc(1, 3, 37)
normal gg
+ " Test list + listchars "precedes", where there is always 1 overlap
+ " regardless of number and cpo-=n.
+ setl number list listchars=precedes:< cpo-=n
+ call s:check_col_calc(5, 1, 1)
+ exe "normal 2|\<C-E>"
+ call s:check_col_calc(6, 1, 18)
+ norm h
+ call s:check_col_calc(5, 2, 17)
+ normal gg
+
bwipe!
endfunc
*** ../vim-9.0.1550/src/version.c 2023-05-13 13:55:05.842074029 +0100
--- src/version.c 2023-05-13 14:07:26.098185014 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1551,
/**/
--
The only backup you need is the one that you didn't have time for.
(Murphy)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230513131247.EB6451C1B21%40moolenaar.net.