Blame SOURCES/7.4.353

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.353
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.353
22c937
Problem:    'linebreak' doesn't work with the 'list' option.
22c937
Solution:   Make it work. (Christian Brabandt)
22c937
Files:	    src/charset.c, src/screen.c,
22c937
	    src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
22c937
	    src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
22c937
	    src/testdir/Make_vms.mms, src/testdir/Makefile,
22c937
	    src/testdir/test_listlbr.in, src/testdir/test_listlbr.ok
22c937
22c937
22c937
*** ../vim-7.4.352/src/charset.c	2014-07-02 19:37:38.462354956 +0200
22c937
--- src/charset.c	2014-07-02 19:47:21.602363892 +0200
22c937
***************
22c937
*** 1120,1126 ****
22c937
      if (wp->w_p_lbr
22c937
  	    && vim_isbreak(c)
22c937
  	    && !vim_isbreak(s[1])
22c937
- 	    && !wp->w_p_list
22c937
  	    && wp->w_p_wrap
22c937
  # ifdef FEAT_VERTSPLIT
22c937
  	    && wp->w_width != 0
22c937
--- 1120,1125 ----
22c937
*** ../vim-7.4.352/src/screen.c	2014-07-02 17:16:51.330225522 +0200
22c937
--- src/screen.c	2014-07-02 19:51:42.082367883 +0200
22c937
***************
22c937
*** 2843,2848 ****
22c937
--- 2843,2849 ----
22c937
      char_u	extra[18];		/* "%ld" and 'fdc' must fit in here */
22c937
      int		n_extra = 0;		/* number of extra chars */
22c937
      char_u	*p_extra = NULL;	/* string of extra chars, plus NUL */
22c937
+     char_u	*p_extra_free = NULL;   /* p_extra needs to be freed */
22c937
      int		c_extra = NUL;		/* extra chars, all the same */
22c937
      int		extra_attr = 0;		/* attributes when n_extra != 0 */
22c937
      static char_u *at_end_str = (char_u *)""; /* used for p_extra when
22c937
***************
22c937
*** 4053,4058 ****
22c937
--- 4054,4064 ----
22c937
  	}
22c937
  	else
22c937
  	{
22c937
+ 	    if (p_extra_free != NULL)
22c937
+ 	    {
22c937
+ 		vim_free(p_extra_free);
22c937
+ 		p_extra_free = NULL;
22c937
+ 	    }
22c937
  	    /*
22c937
  	     * Get a character from the line itself.
22c937
  	     */
22c937
***************
22c937
*** 4424,4431 ****
22c937
  		/*
22c937
  		 * Found last space before word: check for line break.
22c937
  		 */
22c937
! 		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
22c937
! 							     && !wp->w_p_list)
22c937
  		{
22c937
  		    char_u *p = ptr - (
22c937
  # ifdef FEAT_MBYTE
22c937
--- 4430,4436 ----
22c937
  		/*
22c937
  		 * Found last space before word: check for line break.
22c937
  		 */
22c937
! 		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
22c937
  		{
22c937
  		    char_u *p = ptr - (
22c937
  # ifdef FEAT_MBYTE
22c937
***************
22c937
*** 4433,4439 ****
22c937
  # endif
22c937
  				1);
22c937
  		    /* TODO: is passing p for start of the line OK? */
22c937
! 		    n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol,
22c937
  								    NULL) - 1;
22c937
  		    c_extra = ' ';
22c937
  		    if (vim_iswhite(c))
22c937
--- 4438,4444 ----
22c937
  # endif
22c937
  				1);
22c937
  		    /* TODO: is passing p for start of the line OK? */
22c937
! 		    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
22c937
  								    NULL) - 1;
22c937
  		    c_extra = ' ';
22c937
  		    if (vim_iswhite(c))
22c937
***************
22c937
*** 4443,4449 ****
22c937
  			    /* See "Tab alignment" below. */
22c937
  			    FIX_FOR_BOGUSCOLS;
22c937
  #endif
22c937
! 			c = ' ';
22c937
  		    }
22c937
  		}
22c937
  #endif
22c937
--- 4448,4455 ----
22c937
  			    /* See "Tab alignment" below. */
22c937
  			    FIX_FOR_BOGUSCOLS;
22c937
  #endif
22c937
! 			if (!wp->w_p_list)
22c937
! 			    c = ' ';
22c937
  		    }
22c937
  		}
22c937
  #endif
22c937
***************
22c937
*** 4483,4491 ****
22c937
  		 */
22c937
  		if (c == TAB && (!wp->w_p_list || lcs_tab1))
22c937
  		{
22c937
  		    /* tab amount depends on current column */
22c937
! 		    n_extra = (int)wp->w_buffer->b_p_ts
22c937
  					- vcol % (int)wp->w_buffer->b_p_ts - 1;
22c937
  #ifdef FEAT_CONCEAL
22c937
  		    /* Tab alignment should be identical regardless of
22c937
  		     * 'conceallevel' value. So tab compensates of all
22c937
--- 4489,4538 ----
22c937
  		 */
22c937
  		if (c == TAB && (!wp->w_p_list || lcs_tab1))
22c937
  		{
22c937
+ 		    int tab_len = 0;
22c937
  		    /* tab amount depends on current column */
22c937
! 		    tab_len = (int)wp->w_buffer->b_p_ts
22c937
  					- vcol % (int)wp->w_buffer->b_p_ts - 1;
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ 		    if (!wp->w_p_lbr)
22c937
+ #endif
22c937
+ 		    /* tab amount depends on current column */
22c937
+ 			n_extra = tab_len;
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ 		    else
22c937
+ 		    {
22c937
+ 			char_u *p;
22c937
+ 			int	len = n_extra;
22c937
+ 			int	i;
22c937
+ 			int	saved_nextra = n_extra;
22c937
+ 
22c937
+ 			/* if n_extra > 0, it gives the number of chars, to
22c937
+ 			 * use for a tab, else we need to calculate the width
22c937
+ 			 * for a tab */
22c937
+ #ifdef FEAT_MBYTE
22c937
+ 			len = (tab_len * mb_char2len(lcs_tab2));
22c937
+ 			if (n_extra > 0)
22c937
+ 			    len += n_extra - tab_len;
22c937
+ #endif
22c937
+ 			c = lcs_tab1;
22c937
+ 			p = alloc((unsigned)(len + 1));
22c937
+ 			vim_memset(p, ' ', len);
22c937
+ 			p[len] = NUL;
22c937
+ 			p_extra_free = p;
22c937
+ 			for (i = 0; i < tab_len; i++)
22c937
+ 			{
22c937
+ #ifdef FEAT_MBYTE
22c937
+ 			    mb_char2bytes(lcs_tab2, p);
22c937
+ 			    p += mb_char2len(lcs_tab2);
22c937
+ 			    n_extra += mb_char2len(lcs_tab2)
22c937
+ 						 - (saved_nextra > 0 ? 1 : 0);
22c937
+ #else
22c937
+ 			    p[i] = lcs_tab2;
22c937
+ #endif
22c937
+ 			}
22c937
+ 			p_extra = p_extra_free;
22c937
+ 		    }
22c937
+ #endif
22c937
  #ifdef FEAT_CONCEAL
22c937
  		    /* Tab alignment should be identical regardless of
22c937
  		     * 'conceallevel' value. So tab compensates of all
22c937
***************
22c937
*** 4501,4508 ****
22c937
  		    if (wp->w_p_list)
22c937
  		    {
22c937
  			c = lcs_tab1;
22c937
! 			c_extra = lcs_tab2;
22c937
! 			n_attr = n_extra + 1;
22c937
  			extra_attr = hl_attr(HLF_8);
22c937
  			saved_attr2 = char_attr; /* save current attr */
22c937
  #ifdef FEAT_MBYTE
22c937
--- 4548,4560 ----
22c937
  		    if (wp->w_p_list)
22c937
  		    {
22c937
  			c = lcs_tab1;
22c937
! #ifdef FEAT_LINEBREAK
22c937
! 			if (wp->w_p_lbr)
22c937
! 			    c_extra = NUL; /* using p_extra from above */
22c937
! 			else
22c937
! #endif
22c937
! 			    c_extra = lcs_tab2;
22c937
! 			n_attr = tab_len + 1;
22c937
  			extra_attr = hl_attr(HLF_8);
22c937
  			saved_attr2 = char_attr; /* save current attr */
22c937
  #ifdef FEAT_MBYTE
22c937
***************
22c937
*** 4598,4606 ****
22c937
  		    if ((dy_flags & DY_UHEX) && wp->w_p_rl)
22c937
  			rl_mirror(p_extra);	/* reverse "<12>" */
22c937
  #endif
22c937
- 		    n_extra = byte2cells(c) - 1;
22c937
  		    c_extra = NUL;
22c937
! 		    c = *p_extra++;
22c937
  		    if (!attr_pri)
22c937
  		    {
22c937
  			n_attr = n_extra + 1;
22c937
--- 4650,4674 ----
22c937
  		    if ((dy_flags & DY_UHEX) && wp->w_p_rl)
22c937
  			rl_mirror(p_extra);	/* reverse "<12>" */
22c937
  #endif
22c937
  		    c_extra = NUL;
22c937
! #ifdef FEAT_LINEBREAK
22c937
! 		    if (wp->w_p_lbr)
22c937
! 		    {
22c937
! 			char_u *p;
22c937
! 
22c937
! 			c = *p_extra;
22c937
! 			p = alloc((unsigned)n_extra + 1);
22c937
! 			vim_memset(p, ' ', n_extra);
22c937
! 			STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
22c937
! 			p[n_extra] = NUL;
22c937
! 			p_extra_free = p_extra = p;
22c937
! 		    }
22c937
! 		    else
22c937
! #endif
22c937
! 		    {
22c937
! 			n_extra = byte2cells(c) - 1;
22c937
! 			c = *p_extra++;
22c937
! 		    }
22c937
  		    if (!attr_pri)
22c937
  		    {
22c937
  			n_attr = n_extra + 1;
22c937
*** ../vim-7.4.352/src/testdir/Make_amiga.mak	2014-06-25 14:39:35.110348584 +0200
22c937
--- src/testdir/Make_amiga.mak	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 38,43 ****
22c937
--- 38,44 ----
22c937
  		test104.out test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
  		test_breakindent.out \
22c937
+ 		test_listlbr.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
***************
22c937
*** 165,169 ****
22c937
--- 166,171 ----
22c937
  test107.out: test107.in
22c937
  test_autoformat_join.out: test_autoformat_join.in
22c937
  test_breakindent.out: test_breakindent.in
22c937
+ test_listlbr.out: test_listlbr.in
22c937
  test_eval.out: test_eval.in
22c937
  test_options.out: test_options.in
22c937
*** ../vim-7.4.352/src/testdir/Make_dos.mak	2014-06-25 14:39:35.110348584 +0200
22c937
--- src/testdir/Make_dos.mak	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 37,42 ****
22c937
--- 37,43 ----
22c937
  		test105.out test106.out  test107.out\
22c937
  		test_autoformat_join.out \
22c937
  		test_breakindent.out \
22c937
+ 		test_listlbr \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
*** ../vim-7.4.352/src/testdir/Make_ming.mak	2014-06-25 14:39:35.110348584 +0200
22c937
--- src/testdir/Make_ming.mak	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 57,62 ****
22c937
--- 57,63 ----
22c937
  		test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
  		test_breakindent.out \
22c937
+ 		test_listlbr.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
*** ../vim-7.4.352/src/testdir/Make_os2.mak	2014-06-25 14:39:35.114348584 +0200
22c937
--- src/testdir/Make_os2.mak	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 40,45 ****
22c937
--- 40,46 ----
22c937
  		test_autoformat_join.out \
22c937
  		test_eval.out \
22c937
  		test_breakindent.out \
22c937
+ 		test_listlbr.out \
22c937
  		test_options.out
22c937
  
22c937
  .SUFFIXES: .in .out
22c937
*** ../vim-7.4.352/src/testdir/Make_vms.mms	2014-06-25 14:39:35.114348584 +0200
22c937
--- src/testdir/Make_vms.mms	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 98,103 ****
22c937
--- 98,104 ----
22c937
  	 test105.out test106.out test107.out \
22c937
  	 test_autoformat_join.out \
22c937
  	 test_breakindent.out \
22c937
+ 	 test_listlbr.out \
22c937
  	 test_eval.out \
22c937
  	 test_options.out
22c937
  
22c937
*** ../vim-7.4.352/src/testdir/Makefile	2014-06-25 14:39:35.114348584 +0200
22c937
--- src/testdir/Makefile	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 35,40 ****
22c937
--- 35,41 ----
22c937
  		test104.out test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
  		test_breakindent.out \
22c937
+ 		test_listlbr.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
*** ../vim-7.4.352/src/testdir/test_listlbr.in	2014-07-02 19:58:25.642374067 +0200
22c937
--- src/testdir/test_listlbr.in	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 0 ****
22c937
--- 1,62 ----
22c937
+ Test for linebreak and list option
22c937
+ 
22c937
+ STARTTEST
22c937
+ :so small.vim
22c937
+ :if !exists("+linebreak") | e! test.ok | w! test.out | qa! | endif
22c937
+ :10new|:vsp|:vert resize 20
22c937
+ :put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \"
22c937
+ :norm! zt
22c937
+ :set ts=4 sw=4 sts=4 linebreak sbr=+ wrap
22c937
+ :fu! ScreenChar(width)
22c937
+ :	let c=''
22c937
+ :	for j in range(1,4)
22c937
+ :	    for i in range(1,a:width)
22c937
+ :	    	let c.=nr2char(screenchar(j, i))
22c937
+ :	    endfor
22c937
+ :           let c.="\n"
22c937
+ :	endfor
22c937
+ :	return c
22c937
+ :endfu
22c937
+ :fu! DoRecordScreen()
22c937
+ :	wincmd l
22c937
+ :	$put =printf(\"\n%s\", g:test)
22c937
+ :	$put =g:line
22c937
+ :	wincmd p
22c937
+ :endfu
22c937
+ :let g:test="Test 1: set linebreak"
22c937
+ :redraw!
22c937
+ :let line=ScreenChar(winwidth(0))
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test="Test 2: set linebreak + set list"
22c937
+ :set linebreak list listchars=
22c937
+ :redraw!
22c937
+ :let line=ScreenChar(winwidth(0))
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test ="Test 3: set linebreak + set list + fancy listchars"
22c937
+ :exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
22c937
+ :redraw!
22c937
+ :let line=ScreenChar(winwidth(0))
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test ="Test 4: set linebreak nolist"
22c937
+ :set nolist linebreak
22c937
+ :redraw!
22c937
+ :let line=ScreenChar(winwidth(0))
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test ="Test 5: set nolinebreak list"
22c937
+ :set list nolinebreak
22c937
+ :redraw!
22c937
+ :let line=ScreenChar(winwidth(0))
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test ="Test 6: set linebreak with tab and 1 line as long as screen: should break!"
22c937
+ :set nolist linebreak ts=8
22c937
+ :let line="1\t".repeat('a', winwidth(0)-2)
22c937
+ :$put =line
22c937
+ :$
22c937
+ :norm! zt
22c937
+ :redraw!
22c937
+ :let line=ScreenChar(winwidth(0))
22c937
+ :call DoRecordScreen()
22c937
+ :%w! test.out
22c937
+ :qa!
22c937
+ ENDTEST
22c937
+ dummy text
22c937
*** ../vim-7.4.352/src/testdir/test_listlbr.ok	2014-07-02 19:58:25.646374067 +0200
22c937
--- src/testdir/test_listlbr.ok	2014-07-02 19:47:21.610363892 +0200
22c937
***************
22c937
*** 0 ****
22c937
--- 1,39 ----
22c937
+ 
22c937
+ 	abcdef hijklmn	pqrstuvwxyz 1060ABCDEFGHIJKLMNOP 
22c937
+ 
22c937
+ Test 1: set linebreak
22c937
+     abcdef          
22c937
+ +hijklmn            
22c937
+ +pqrstuvwxyz 1060ABC
22c937
+ +DEFGHIJKLMNOP      
22c937
+ 
22c937
+ Test 2: set linebreak + set list
22c937
+ ^Iabcdef hijklmn^I  
22c937
+ +pqrstuvwxyz 1060ABC
22c937
+ +DEFGHIJKLMNOP      
22c937
+                     
22c937
+ 
22c937
+ Test 3: set linebreak + set list + fancy listchars
22c937
+ ▕———abcdef          
22c937
+ +hijklmn▕———        
22c937
+ +pqrstuvwxyz␣1060ABC
22c937
+ +DEFGHIJKLMNOPˑ¶    
22c937
+ 
22c937
+ Test 4: set linebreak nolist
22c937
+     abcdef          
22c937
+ +hijklmn            
22c937
+ +pqrstuvwxyz 1060ABC
22c937
+ +DEFGHIJKLMNOP      
22c937
+ 
22c937
+ Test 5: set nolinebreak list
22c937
+ ▕———abcdef hijklmn▕—
22c937
+ +pqrstuvwxyz␣1060ABC
22c937
+ +DEFGHIJKLMNOPˑ¶    
22c937
+ ¶                   
22c937
+ 1	aaaaaaaaaaaaaaaaaa
22c937
+ 
22c937
+ Test 6: set linebreak with tab and 1 line as long as screen: should break!
22c937
+ 1                   
22c937
+ +aaaaaaaaaaaaaaaaaa 
22c937
+ ~                   
22c937
+ ~                   
22c937
*** ../vim-7.4.352/src/version.c	2014-07-02 19:37:38.462354956 +0200
22c937
--- src/version.c	2014-07-02 19:57:44.066373430 +0200
22c937
***************
22c937
*** 736,737 ****
22c937
--- 736,739 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     353,
22c937
  /**/
22c937
22c937
-- 
22c937
FATHER:    You only killed the bride's father - that's all -
22c937
LAUNCELOT: Oh dear, I didn't really mean to...
22c937
FATHER:    Didn't mean to?  You put your sword right through his head!
22c937
LAUNCELOT: Gosh - Is he all right?
22c937
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///