]> granicus.if.org Git - vim/commitdiff
patch 8.2.2903: cursor position wrong on wrapped line with 'signcolumn' v8.2.2903
authorBram Moolenaar <Bram@vim.org>
Sat, 29 May 2021 15:56:37 +0000 (17:56 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 29 May 2021 15:56:37 +0000 (17:56 +0200)
Problem:    Cursor position wrong on wrapped line with 'signcolumn'.
Solution:   Don't add space for showbreak twice. (Christian Brabandt,
            closes #8262)

src/drawline.c
src/testdir/test_display.vim
src/version.c

index 13be022a93d708ee78c1b7b1d510053fd200f7b9..7b6777e64c13857c75514307008be508b559fbcf 100644 (file)
@@ -1981,6 +1981,12 @@ win_line(
                    // TODO: is passing p for start of the line OK?
                    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
                                                                    NULL) - 1;
+
+                   // We have just drawn the showbreak value, no need to add
+                   // space for it again
+                   if (vcol == vcol_sbr)
+                       n_extra -= MB_CHARLEN(get_showbreak_value(wp));
+
                    if (c == TAB && n_extra + col > wp->w_width)
 # ifdef FEAT_VARTABS
                        n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts,
index 754046f2aedb6e6a252a3c6907d4c1674c58167e..964220cacda4422193d555074264e0cf89c7b891 100644 (file)
@@ -334,4 +334,21 @@ func Test_fold_fillchars()
   set fillchars& fdc& foldmethod& foldenable&
 endfunc
 
+func Test_display_linebreak_breakat()
+  new
+  vert resize 25
+  let _breakat = &breakat
+  setl signcolumn=yes linebreak breakat=) showbreak=+\ 
+  call setline(1, repeat('x', winwidth(0) - 2) .. ')abc')
+  let lines = ScreenLines([1, 2], 25)
+  let expected = [
+          \ '  xxxxxxxxxxxxxxxxxxxxxxx',
+          \ '  + )abc                 '
+          \ ]
+  call assert_equal(expected, lines)
+  %bw!
+  let &breakat=_breakat
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index a1cda6333a43faa4e3007df7d9e05fd9b0177757..c94183bfdb7a1f622e8c52cfe040133f28a36ad7 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2903,
 /**/
     2902,
 /**/