Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.4.587
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.587
Problem:    Conceal does not work properly with 'linebreak'. (cs86661)
Solution:   Save and restore boguscols. (Christian Brabandt)
Files:	    src/screen.c, src/testdir/test_listlbr_utf8.in,
	    src/testdir/test_listlbr_utf8.ok


*** ../vim-7.4.586/src/screen.c	2015-01-14 19:35:10.967756099 +0100
--- src/screen.c	2015-01-20 18:57:39.114986010 +0100
***************
*** 3003,3008 ****
--- 3003,3009 ----
  					   wrapping */
      int		vcol_off	= 0;	/* offset for concealed characters */
      int		did_wcol	= FALSE;
+     int		old_boguscols   = 0;
  # define VCOL_HLC (vcol - vcol_off)
  # define FIX_FOR_BOGUSCOLS \
      { \
***************
*** 3010,3015 ****
--- 3011,3017 ----
  	vcol -= vcol_off; \
  	vcol_off = 0; \
  	col -= boguscols; \
+ 	old_boguscols = boguscols; \
  	boguscols = 0; \
      }
  #else
***************
*** 4545,4554 ****
  			int	saved_nextra = n_extra;
  
  #ifdef FEAT_CONCEAL
! 			if (is_concealing && vcol_off > 0)
  			    /* there are characters to conceal */
  			    tab_len += vcol_off;
  #endif
  			/* if n_extra > 0, it gives the number of chars, to
  			 * use for a tab, else we need to calculate the width
  			 * for a tab */
--- 4547,4562 ----
  			int	saved_nextra = n_extra;
  
  #ifdef FEAT_CONCEAL
! 			if ((is_concealing || boguscols > 0) && vcol_off > 0)
  			    /* there are characters to conceal */
  			    tab_len += vcol_off;
+ 			/* boguscols before FIX_FOR_BOGUSCOLS macro from above
+ 			 */
+ 			if (wp->w_p_list && lcs_tab1 && old_boguscols > 0
+ 							 && n_extra > tab_len)
+ 			    tab_len += n_extra - tab_len;
  #endif
+ 
  			/* if n_extra > 0, it gives the number of chars, to
  			 * use for a tab, else we need to calculate the width
  			 * for a tab */
***************
*** 4577,4583 ****
  #ifdef FEAT_CONCEAL
  			/* n_extra will be increased by FIX_FOX_BOGUSCOLS
  			 * macro below, so need to adjust for that here */
! 			if (is_concealing && vcol_off > 0)
  			    n_extra -= vcol_off;
  #endif
  		    }
--- 4585,4591 ----
  #ifdef FEAT_CONCEAL
  			/* n_extra will be increased by FIX_FOX_BOGUSCOLS
  			 * macro below, so need to adjust for that here */
! 			if ((is_concealing || boguscols > 0) && vcol_off > 0)
  			    n_extra -= vcol_off;
  #endif
  		    }
***************
*** 4590,4595 ****
--- 4598,4609 ----
  		     * the tab can be longer than 'tabstop' when there
  		     * are concealed characters. */
  		    FIX_FOR_BOGUSCOLS;
+ 		    /* Make sure, the highlighting for the tab char will be
+ 		     * correctly set further below (effectively reverts the
+ 		     * FIX_FOR_BOGSUCOLS macro */
+ 		    if (old_boguscols > 0 && n_extra > tab_len && wp->w_p_list
+ 								  && lcs_tab1)
+ 			tab_len += n_extra - tab_len;
  #endif
  #ifdef FEAT_MBYTE
  		    mb_utf8 = FALSE;	/* don't draw as UTF-8 */
*** ../vim-7.4.586/src/testdir/test_listlbr_utf8.in	2014-07-30 16:44:17.499534723 +0200
--- src/testdir/test_listlbr_utf8.in	2015-01-20 18:55:32.060370459 +0100
***************
*** 9,17 ****
  :put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \"
  :norm! zt
  :set ts=4 sw=4 sts=4 linebreak sbr=+ wrap
! :fu! ScreenChar(width)
  :	let c=''
! :	for j in range(1,4)
  :	    for i in range(1,a:width)
  :	    	let c.=nr2char(screenchar(j, i))
  :	    endfor
--- 9,17 ----
  :put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \"
  :norm! zt
  :set ts=4 sw=4 sts=4 linebreak sbr=+ wrap
! :fu! ScreenChar(width, lines)
  :	let c=''
! :	for j in range(1,a:lines)
  :	    for i in range(1,a:width)
  :	    	let c.=nr2char(screenchar(j, i))
  :	    endfor
***************
*** 28,40 ****
  :let g:test ="Test 1: set linebreak + set list + fancy listchars"
  :exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
  :redraw!
! :let line=ScreenChar(winwidth(0))
  :call DoRecordScreen()
  :"
  :let g:test ="Test 2: set nolinebreak list"
  :set list nolinebreak
  :redraw!
! :let line=ScreenChar(winwidth(0))
  :call DoRecordScreen()
  :"
  :let g:test ="Test 3: set linebreak nolist"
--- 28,40 ----
  :let g:test ="Test 1: set linebreak + set list + fancy listchars"
  :exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
  :redraw!
! :let line=ScreenChar(winwidth(0),4)
  :call DoRecordScreen()
  :"
  :let g:test ="Test 2: set nolinebreak list"
  :set list nolinebreak
  :redraw!
! :let line=ScreenChar(winwidth(0),4)
  :call DoRecordScreen()
  :"
  :let g:test ="Test 3: set linebreak nolist"
***************
*** 43,51 ****
  :norm! zt
  :set nolist linebreak
  :redraw!
! :let line=ScreenChar(winwidth(0))
  :call DoRecordScreen()
- :"
  :%w! test.out
  :qa!
  ENDTEST
--- 43,61 ----
  :norm! zt
  :set nolist linebreak
  :redraw!
! :let line=ScreenChar(winwidth(0),4)
! :call DoRecordScreen()
! :let g:test ="Test 4: set linebreak list listchars and concealing"
! :let c_defines=['#define ABCDE		1','#define ABCDEF		1','#define ABCDEFG		1','#define ABCDEFGH	1', '#define MSG_MODE_FILE			1','#define MSG_MODE_CONSOLE		2','#define MSG_MODE_FILE_AND_CONSOLE	3','#define MSG_MODE_FILE_THEN_CONSOLE	4']
! :call append('$', c_defines)
! :vert resize 40
! :$-7
! :norm! zt
! :set list linebreak listchars=tab:>- cole=1
! :syn match Conceal conceal cchar=>'AB\|MSG_MODE'
! :redraw!
! :let line=ScreenChar(winwidth(0),7)
  :call DoRecordScreen()
  :%w! test.out
  :qa!
  ENDTEST
*** ../vim-7.4.586/src/testdir/test_listlbr_utf8.ok	2014-07-30 16:44:17.499534723 +0200
--- src/testdir/test_listlbr_utf8.ok	2015-01-20 18:55:32.060370459 +0100
***************
*** 19,21 ****
--- 19,38 ----
  ~                   
  ~                   
  ~                   
+ #define ABCDE		1
+ #define ABCDEF		1
+ #define ABCDEFG		1
+ #define ABCDEFGH	1
+ #define MSG_MODE_FILE			1
+ #define MSG_MODE_CONSOLE		2
+ #define MSG_MODE_FILE_AND_CONSOLE	3
+ #define MSG_MODE_FILE_THEN_CONSOLE	4
+ 
+ Test 4: set linebreak list listchars and concealing
+ #define ABCDE>-->---1                   
+ #define >CDEF>-->---1                   
+ #define >CDEFG>->---1                   
+ #define >CDEFGH>----1                   
+ #define >_FILE>--------->--->---1       
+ #define >_CONSOLE>---------->---2       
+ #define >_FILE_AND_CONSOLE>---------3   
*** ../vim-7.4.586/src/version.c	2015-01-20 17:27:18.154026317 +0100
--- src/version.c	2015-01-20 19:01:11.448672365 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     587,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
93. New mail alarm on your palmtop annoys other churchgoers.

 /// Bram Moolenaar -- Bram@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    ///