Hi cs86661!

On Di, 09 Dez 2014, cs86661 wrote:

> thank you. I patch it into vim 7.4.542. It seems to be correct ...almost!
> 
> I found it has another problem, maybe I should not use this conceal feature. 
> :(
> 
> example:
> 
> 1. open test_2.c.
> 
> 2. change settings.
> :set list
> :set listchars=tab:\|-
> :syntax match Conceal conceal cchar=> 'MSG_MODE_'
> :set conceallevel=1
> 
> 3. problem setting, some tab char replace by spaces.
> :set lbr
> 

> #include <stdio.h>
> 
> #define ABC           1
> #define ABCD          1
> #define ABCDE         1
> 
> #define AB_C  1
> #define AB_CD 1
> #define AB_CDE        1
> 
> #define MSG_MODE_FILE                 0
> #define MSG_MODE_CONSOLE              1
> #define MSG_MODE_FILE_AND_CONSOLE     2
> #define MSG_MODE_FILE_THEN_CONSOLE    3
> 
> int main()
> {
>   return 0;
> }

Please check attached patch. That should fix both your problems and 
includes a test.


Best,
Christian
-- 
Neue Viren:
Amnesty International Virus: Dieser Virus setzt sich in den oberen
Speicherbereich und führt automatisch ein Undelete aller gelöschten
Dateien durch.

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/screen.c b/src/screen.c
--- a/src/screen.c
+++ b/src/screen.c
@@ -3000,6 +3000,7 @@ win_line(wp, lnum, startrow, endrow, noc
 					   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 \
     { \
@@ -3007,6 +3008,7 @@ win_line(wp, lnum, startrow, endrow, noc
 	vcol -= vcol_off; \
 	vcol_off = 0; \
 	col -= boguscols; \
+	old_boguscols = boguscols; \
 	boguscols = 0; \
     }
 #else
@@ -4527,10 +4529,14 @@ win_line(wp, lnum, startrow, endrow, noc
 			int	saved_nextra = n_extra;
 
 #ifdef FEAT_CONCEAL
-			if (is_concealing && vcol_off > 0)
+			if ((is_concealing || boguscols > 0) && vcol_off > 0)
 			    /* there are characters to conceal */
 			    tab_len += vcol_off;
-#endif
+			/* 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 */
@@ -4559,7 +4565,7 @@ win_line(wp, lnum, startrow, endrow, noc
 #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)
+			if ((is_concealing || boguscols > 0) && vcol_off > 0)
 			    n_extra -= vcol_off;
 #endif
 		    }
@@ -4572,6 +4578,10 @@ win_line(wp, lnum, startrow, endrow, noc
 		     * 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 */
diff --git a/src/testdir/test_listlbr_utf8.in b/src/testdir/test_listlbr_utf8.in
--- a/src/testdir/test_listlbr_utf8.in
+++ b/src/testdir/test_listlbr_utf8.in
@@ -9,9 +9,9 @@ STARTTEST
 :put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \"
 :norm! zt
 :set ts=4 sw=4 sts=4 linebreak sbr=+ wrap
-:fu! ScreenChar(width)
+:fu! ScreenChar(width, lines)
 :	let c=''
-:	for j in range(1,4)
+:	for j in range(1,a:lines)
 :	    for i in range(1,a:width)
 :	    	let c.=nr2char(screenchar(j, i))
 :	    endfor
@@ -28,13 +28,13 @@ STARTTEST
 :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))
+: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))
+:let line=ScreenChar(winwidth(0),4)
 :call DoRecordScreen()
 :"
 :let g:test ="Test 3: set linebreak nolist"
@@ -43,9 +43,19 @@ STARTTEST
 :norm! zt
 :set nolist linebreak
 :redraw!
-:let line=ScreenChar(winwidth(0))
+: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
diff --git a/src/testdir/test_listlbr_utf8.ok b/src/testdir/test_listlbr_utf8.ok
--- a/src/testdir/test_listlbr_utf8.ok
+++ b/src/testdir/test_listlbr_utf8.ok
@@ -19,3 +19,20 @@ Test 3: set linebreak nolist
 ~                   
 ~                   
 ~                   
+#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   

Raspunde prin e-mail lui