Hi,
updated patch attached, that fixes failures in the other tests and 
adjusted to 8.1.0114 and fixes that the test was actually disabled 
(which I did for debugging and forgot to remove before sending).

Best,
Christian
-- 
Das Seltenste, was ich gesehen: ein alter Tyrann.
                -- Thales von Milet (650-560 v.Chr.)

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.
From efce8b10200aa2ba72fb7fab3427108060fd3422 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Sun, 24 Jun 2018 21:09:28 +0200
Subject: [PATCH] Fix remaining issues for vartab feature

This patch does the following:

- fix a memory leak in ex_retab
- prevent a division by zero in tabstop_fromto (coverity CID 1437494)
- Make sure, that the screen drawing code does take the variable tabstop
  into account
- Fix a segfault in screen.c when n_extra < tab_len (which would result
  in a smaller len value which could cause a segfault in the following
  `for (i=0; i<tab_len; i++)` loop (the loop is supposed to be run per
  characters and not per bytes).
- Add a test for 3 (github issue #3076)
---
 src/ex_cmds.c                |  2 +-
 src/option.c                 |  7 +++++-
 src/screen.c                 | 10 +++++++++
 src/testdir/test_vartabs.vim | 41 ++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 994ef0c5e..f546cc560 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -856,7 +856,6 @@ ex_retab(exarg_T *eap)
 	{
 	    set_string_option_direct((char_u *)"vts", -1, new_ts_str,
 							OPT_FREE|OPT_LOCAL, 0);
-	    vim_free(new_ts_str);
 	    curbuf->b_p_vts_array = new_vts_array;
 	    vim_free(old_vts_ary);
 	}
@@ -867,6 +866,7 @@ ex_retab(exarg_T *eap)
 	    curbuf->b_p_ts = tabstop_first(new_vts_array);
 	    vim_free(new_vts_array);
 	}
+	vim_free(new_ts_str);
     }
 #else
     curbuf->b_p_ts = new_ts;
diff --git a/src/option.c b/src/option.c
index 1ba8a8c2e..038620fc7 100644
--- a/src/option.c
+++ b/src/option.c
@@ -12881,8 +12881,13 @@ tabstop_fromto(
     if (vts == NULL || vts[0] == 0)
     {
 	int tabs = 0;
-	int initspc = ts - (start_col % ts);
+	int initspc = 0;
 
+	if (ts == 0)
+	    /* no division by zero */
+	    ts = curbuf->b_p_ts;
+
+	initspc = ts - (start_col % ts);
 	if (spaces >= initspc)
 	{
 	    spaces -= initspc;
diff --git a/src/screen.c b/src/screen.c
index eac50c52c..422ffe51d 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -4753,8 +4753,13 @@ win_line(
 		    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
 								    NULL) - 1;
 		    if (c == TAB && n_extra + col > wp->w_width)
+ #ifdef FEAT_VARTABS
+			n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts,
+					wp->w_buffer->b_p_vts_array) - 1;
+#else
 			n_extra = (int)wp->w_buffer->b_p_ts
 				       - vcol % (int)wp->w_buffer->b_p_ts - 1;
+ #endif
 
 # ifdef FEAT_MBYTE
 		    c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' ';
@@ -4897,6 +4902,11 @@ win_line(
 			p_extra_free = p;
 			for (i = 0; i < tab_len; i++)
 			{
+			    if (*p == NUL)
+			    {
+				tab_len = i;
+				break;
+			    }
 #ifdef FEAT_MBYTE
 			    mb_char2bytes(lcs_tab2, p);
 			    p += mb_char2len(lcs_tab2);
diff --git a/src/testdir/test_vartabs.vim b/src/testdir/test_vartabs.vim
index 85914f6bc..c43e17830 100644
--- a/src/testdir/test_vartabs.vim
+++ b/src/testdir/test_vartabs.vim
@@ -4,6 +4,11 @@ if !has("vartabs")
   finish
 endif
 
+source view_util.vim
+function! s:compare_lines(expect, actual)
+  call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
+endfunction
+
 func! Test_vartabs()
   new
   %d
@@ -255,3 +260,39 @@ func! Test_vartabs_breakindent()
 
   bwipeout!
 endfunc
+
+func! Test_vartabs_linebreak()
+  if winwidth(0) < 40
+    return
+  endif
+  new
+  40vnew
+  %d
+  setl linebreak vartabstop=10,20,30,40
+  call setline(1, "\tx\tx\tx\tx")
+
+  let expect = ['          x                             ',
+        \       'x                   x                   ',
+        \       'x                                       ']
+  let lines = ScreenLines([1, 3], winwidth(0))
+  call s:compare_lines(expect, lines)
+  setl list listchars=tab:>-
+  let expect = ['>---------x>------------------          ',
+        \       'x>------------------x>------------------',
+        \       'x                                       ']
+  let lines = ScreenLines([1, 3], winwidth(0))
+  call s:compare_lines(expect, lines)
+  setl linebreak vartabstop=40
+  let expect = ['>---------------------------------------',
+        \       'x>--------------------------------------',
+        \       'x>--------------------------------------',
+        \       'x>--------------------------------------',
+        \       'x                                       ']
+  let lines = ScreenLines([1, 5], winwidth(0))
+  call s:compare_lines(expect, lines)
+
+  " cleanup
+  bw!
+  bw!
+  set nolist listchars&vim
+endfunc
-- 
2.17.0

Raspunde prin e-mail lui