Skip to content

Commit a084914

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.1836: 'culopt' "screenline" not redrawn with line("w0") and :retab
Problem: 'cursorlineopt' "screenline" isn't redrawn when moving cursor and then using line("w0") and :retab that does nothing. Solution: Call redraw_for_cursorcolumn() when setting a valid w_virtcol (zeertzjq). closes: #18506 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 474b981 commit a084914

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

src/misc2.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ coladvance_force(colnr_T wcol)
6060
if (wcol == MAXCOL)
6161
curwin->w_valid &= ~VALID_VIRTCOL;
6262
else
63-
{
6463
// Virtcol is valid
65-
curwin->w_valid |= VALID_VIRTCOL;
66-
curwin->w_virtcol = wcol;
67-
}
64+
set_valid_virtcol(curwin, wcol);
6865
return rc;
6966
}
7067

@@ -101,11 +98,8 @@ coladvance(colnr_T wantcol)
10198
if (wantcol == MAXCOL || rc == FAIL)
10299
curwin->w_valid &= ~VALID_VIRTCOL;
103100
else if (*ml_get_cursor() != TAB)
104-
{
105101
// Virtcol is valid when not on a TAB
106-
curwin->w_valid |= VALID_VIRTCOL;
107-
curwin->w_virtcol = wantcol;
108-
}
102+
set_valid_virtcol(curwin, wantcol);
109103
return rc;
110104
}
111105

src/move.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ redraw_for_cursorcolumn(win_T *wp)
193193
}
194194
#endif
195195

196+
/*
197+
* Set wp->w_virtcol to a value ("vcol") that is already valid.
198+
* Handles redrawing if wp->w_virtcol was previously invalid.
199+
*/
200+
void
201+
set_valid_virtcol(win_T *wp, colnr_T vcol)
202+
{
203+
wp->w_virtcol = vcol;
204+
#ifdef FEAT_SYN_HL
205+
redraw_for_cursorcolumn(wp);
206+
#endif
207+
wp->w_valid |= VALID_VIRTCOL;
208+
}
209+
196210
/*
197211
* Calculates how much the 'listchars' "precedes" or 'smoothscroll' "<<<"
198212
* marker overlaps with buffer text for window "wp".

src/proto/move.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* move.c */
22
int adjust_plines_for_skipcol(win_T *wp);
3+
void set_valid_virtcol(win_T *wp, colnr_T vcol);
34
int sms_marker_overlap(win_T *wp, int extra2);
45
void update_topline_redraw(void);
56
void update_topline(void);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|x+0&#ffffff0|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z
2+
> +8&&|x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| |x|y|z| @30
3+
|~+0#4040ff13&| @73
4+
|~| @73
5+
|~| @73
6+
|~| @73
7+
|~| @73
8+
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|7|6| @9|A|l@1|

src/testdir/test_cursorline.vim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,17 @@ func Test_cursorline_screenline_update()
292292
CheckScreendump
293293

294294
let lines =<< trim END
295+
func TestRetab()
296+
let w = winwidth(0)
297+
call cursor([1, w + 1, 0, w + 1])
298+
call line('w0')
299+
retab 8
300+
endfunc
301+
295302
call setline(1, repeat('xyz ', 30))
296-
set cursorline cursorlineopt=screenline
303+
set cursorline cursorlineopt=screenline tabstop=8
297304
inoremap <F2> <Cmd>call cursor(1, 1)<CR>
305+
inoremap <F3> <Cmd>call TestRetab()<CR>
298306
END
299307
call writefile(lines, 'Xcul_screenline', 'D')
300308

@@ -303,6 +311,8 @@ func Test_cursorline_screenline_update()
303311
call VerifyScreenDump(buf, 'Test_cursorline_screenline_1', {})
304312
call term_sendkeys(buf, "\<F2>")
305313
call VerifyScreenDump(buf, 'Test_cursorline_screenline_2', {})
314+
call term_sendkeys(buf, "\<F3>")
315+
call VerifyScreenDump(buf, 'Test_cursorline_screenline_3', {})
306316
call term_sendkeys(buf, "\<Esc>")
307317

308318
call StopVimInTerminal(buf)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1836,
732734
/**/
733735
1835,
734736
/**/

src/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7077,7 +7077,7 @@ set_fraction(win_T *wp)
70777077
* calculate the new scroll position.
70787078
* TODO: Ensure this also works with wrapped lines.
70797079
* Requires a not fully visible cursor line to be allowed at the bottom of
7080-
* a window("zb"), probably only when 'smoothscroll' is also set.
7080+
* a window ("zb"), probably only when 'smoothscroll' is also set.
70817081
*/
70827082
static void
70837083
win_fix_scroll(int resize)

0 commit comments

Comments
 (0)