Patch 8.1.0126
Problem:    Various problems with 'vartabstop'.
Solution:   Fix memory leak.  Fix crash. Add a few more tests. (Christian
            Brabandt, closes #3076)
Files:      src/ex_cmds.c, src/option.c, src/screen.c,
            src/testdir/test_vartabs.vim


*** ../vim-8.1.0125/src/ex_cmds.c       2018-06-28 11:28:04.793455550 +0200
--- src/ex_cmds.c       2018-06-28 20:37:11.354721386 +0200
***************
*** 866,872 ****
        {
            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);
        }
--- 866,871 ----
***************
*** 877,882 ****
--- 876,882 ----
            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;
*** ../vim-8.1.0125/src/option.c        2018-06-28 15:29:48.081656098 +0200
--- src/option.c        2018-06-28 20:40:51.173370370 +0200
***************
*** 12870,12876 ****
  tabstop_fromto(
        colnr_T start_col,
        colnr_T end_col,
!       int     ts,
        int     *vts,
        int     *ntabs,
        int     *nspcs)
--- 12870,12876 ----
  tabstop_fromto(
        colnr_T start_col,
        colnr_T end_col,
!       int     ts_arg,
        int     *vts,
        int     *ntabs,
        int     *nspcs)
***************
*** 12880,12891 ****
      int               padding = 0;
      int               tabcount;
      int               t;
  
      if (vts == NULL || vts[0] == 0)
      {
        int tabs = 0;
!       int initspc = ts - (start_col % ts);
  
        if (spaces >= initspc)
        {
            spaces -= initspc;
--- 12880,12893 ----
      int               padding = 0;
      int               tabcount;
      int               t;
+     int               ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg;
  
      if (vts == NULL || vts[0] == 0)
      {
        int tabs = 0;
!       int initspc = 0;
  
+       initspc = ts - (start_col % ts);
        if (spaces >= initspc)
        {
            spaces -= initspc;
*** ../vim-8.1.0125/src/screen.c        2018-06-25 21:24:47.284934379 +0200
--- src/screen.c        2018-06-28 20:38:50.538108113 +0200
***************
*** 4753,4765 ****
                    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 : ' ';
--- 4753,4765 ----
                    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 : ' ';
***************
*** 4902,4907 ****
--- 4902,4912 ----
                        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);
*** ../vim-8.1.0125/src/testdir/test_vartabs.vim        2018-06-25 
21:24:47.284934379 +0200
--- src/testdir/test_vartabs.vim        2018-06-28 20:42:19.772833210 +0200
***************
*** 262,282 ****
  endfunc
  
  func! Test_vartabs_linebreak()
!   if winwidth(0) < 80
      return
    endif
    new
!   70vnew
    %d
!   setl linebreak vartabstop=10,15,20,40
    call setline(1, "\tx\tx\tx\tx")
  
!   let lines = ScreenLines([1, 2], winwidth(0))
!   let expect = ['          x              x                   x               
         ',
!         \       '               x                                             
         ']
    call s:compare_lines(expect, lines)
  
    " cleanup
    bw!
    bw!
  endfunc
--- 262,298 ----
  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
*** ../vim-8.1.0125/src/version.c       2018-06-28 19:26:24.321655175 +0200
--- src/version.c       2018-06-28 20:36:19.043047749 +0200
***************
*** 791,792 ****
--- 791,794 ----
  {   /* Add new patch number below this line */
+ /**/
+     126,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
138. You develop a liking for cold coffee.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui