vim-patch:7.4.587 #2622

Problem:    Conceal does not work properly with 'linebreak'. (cs86661)
Solution:   Save and restore boguscols. (Christian Brabandt)

https://github.com/vim/vim/commit/v7-4-587
This commit is contained in:
David Bürgin
2015-05-09 16:03:07 +02:00
committed by Justin M. Keyes
parent 6a1d89462b
commit af4b0a76a7
3 changed files with 51 additions and 9 deletions

View File

@@ -2174,6 +2174,7 @@ win_line (
wrapping */ wrapping */
int vcol_off = 0; /* offset for concealed characters */ int vcol_off = 0; /* offset for concealed characters */
int did_wcol = FALSE; int did_wcol = FALSE;
int old_boguscols = 0;
# define VCOL_HLC (vcol - vcol_off) # define VCOL_HLC (vcol - vcol_off)
# define FIX_FOR_BOGUSCOLS \ # define FIX_FOR_BOGUSCOLS \
{ \ { \
@@ -2181,6 +2182,7 @@ win_line (
vcol -= vcol_off; \ vcol -= vcol_off; \
vcol_off = 0; \ vcol_off = 0; \
col -= boguscols; \ col -= boguscols; \
old_boguscols = boguscols; \
boguscols = 0; \ boguscols = 0; \
} }
@@ -3369,10 +3371,15 @@ win_line (
int i; int i;
int saved_nextra = n_extra; int saved_nextra = n_extra;
if (is_concealing && vcol_off > 0) { if ((is_concealing || boguscols > 0) && vcol_off > 0) {
// there are characters to conceal // there are characters to conceal
tab_len += vcol_off; 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;
}
/* if n_extra > 0, it gives the number of chars to use for /* 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 */ * a tab, else we need to calculate the width for a tab */
@@ -3394,7 +3401,7 @@ win_line (
// n_extra will be increased by FIX_FOX_BOGUSCOLS // n_extra will be increased by FIX_FOX_BOGUSCOLS
// macro below, so need to adjust for that here // 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; n_extra -= vcol_off;
} }
} }
@@ -3405,6 +3412,13 @@ win_line (
* the tab can be longer than 'tabstop' when there * the tab can be longer than 'tabstop' when there
* are concealed characters. */ * are concealed characters. */
FIX_FOR_BOGUSCOLS; FIX_FOR_BOGUSCOLS;
// Make sure that 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;
}
mb_utf8 = FALSE; /* don't draw as UTF-8 */ mb_utf8 = FALSE; /* don't draw as UTF-8 */
if (wp->w_p_list) { if (wp->w_p_list) {
c = lcs_tab1; c = lcs_tab1;

View File

@@ -196,7 +196,7 @@ static int included_patches[] = {
590, 590,
//589 NA //589 NA
588, 588,
//587, 587,
//586 NA //586 NA
585, 585,
//584 NA //584 NA

View File

@@ -16,9 +16,9 @@ describe('linebreak', function()
put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \" put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \"
norm! zt norm! zt
set ts=4 sw=4 sts=4 linebreak sbr=+ wrap set ts=4 sw=4 sts=4 linebreak sbr=+ wrap
fu! ScreenChar(width) fu! ScreenChar(width, lines)
let c='' let c=''
for j in range(1,4) for j in range(1,a:lines)
for i in range(1,a:width) for i in range(1,a:width)
let c.=nr2char(screenchar(j, i)) let c.=nr2char(screenchar(j, i))
endfor endfor
@@ -35,12 +35,12 @@ describe('linebreak', function()
let g:test ="Test 1: set linebreak + set list + fancy listchars" 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" exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
redraw! redraw!
let line=ScreenChar(winwidth(0)) let line=ScreenChar(winwidth(0),4)
call DoRecordScreen() call DoRecordScreen()
let g:test ="Test 2: set nolinebreak list" let g:test ="Test 2: set nolinebreak list"
set list nolinebreak set list nolinebreak
redraw! redraw!
let line=ScreenChar(winwidth(0)) let line=ScreenChar(winwidth(0),4)
call DoRecordScreen() call DoRecordScreen()
let g:test ="Test 3: set linebreak nolist" let g:test ="Test 3: set linebreak nolist"
$put =\"\t*mask = nil;\" $put =\"\t*mask = nil;\"
@@ -48,7 +48,18 @@ describe('linebreak', function()
norm! zt norm! zt
set nolist linebreak set nolist linebreak
redraw! 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() call DoRecordScreen()
]]) ]])
@@ -74,6 +85,23 @@ describe('linebreak', function()
*mask = nil; *mask = nil;
~ ~
~ ~
~ ]]) ~
#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 ]])
end) end)
end) end)