Skip to content

Commit a06e345

Browse files
committed
patch 8.2.2903: cursor position wrong on wrapped line with 'signcolumn'
Problem: Cursor position wrong on wrapped line with 'signcolumn'. Solution: Don't add space for showbreak twice. (Christian Brabandt, closes #8262)
1 parent 5a6cfb3 commit a06e345

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/drawline.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,12 @@ win_line(
19811981
// TODO: is passing p for start of the line OK?
19821982
n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
19831983
NULL) - 1;
1984+
1985+
// We have just drawn the showbreak value, no need to add
1986+
// space for it again
1987+
if (vcol == vcol_sbr)
1988+
n_extra -= MB_CHARLEN(get_showbreak_value(wp));
1989+
19841990
if (c == TAB && n_extra + col > wp->w_width)
19851991
# ifdef FEAT_VARTABS
19861992
n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts,

src/testdir/test_display.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,21 @@ func Test_fold_fillchars()
334334
set fillchars& fdc& foldmethod& foldenable&
335335
endfunc
336336

337+
func Test_display_linebreak_breakat()
338+
new
339+
vert resize 25
340+
let _breakat = &breakat
341+
setl signcolumn=yes linebreak breakat=) showbreak=+\
342+
call setline(1, repeat('x', winwidth(0) - 2) .. ')abc')
343+
let lines = ScreenLines([1, 2], 25)
344+
let expected = [
345+
\ ' xxxxxxxxxxxxxxxxxxxxxxx',
346+
\ ' + )abc '
347+
\ ]
348+
call assert_equal(expected, lines)
349+
%bw!
350+
let &breakat=_breakat
351+
endfunc
352+
353+
337354
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2903,
753755
/**/
754756
2902,
755757
/**/

0 commit comments

Comments
 (0)