jkunstle / rpms / vim

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