jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.353

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