Merge #7088 from justinmk/vimpatches

This commit is contained in:
Justin M. Keyes 2017-08-12 21:44:12 +02:00 committed by GitHub
commit d42547f322
8 changed files with 909 additions and 28 deletions

View File

@ -7690,6 +7690,7 @@ static void ex_redraw(exarg_T *eap)
RedrawingDisabled = 0;
p_lz = FALSE;
validate_cursor();
update_topline();
update_screen(eap->forceit ? CLEAR :
VIsual_active ? INVERTED :

View File

@ -1924,11 +1924,16 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
if (fill_fold >= 0x80) {
ScreenLinesUC[off + col] = fill_fold;
ScreenLinesC[0][off + col] = 0;
} else
ScreenLines[off + col] = 0x80; // avoid storing zero
} else {
ScreenLinesUC[off + col] = 0;
ScreenLines[off + col] = fill_fold;
}
col++;
} else {
ScreenLines[off + col++] = fill_fold;
}
}
if (text != buf)
xfree(text);
@ -2112,16 +2117,16 @@ win_line (
bool nochange /* not updating for changed text */
)
{
int col; /* visual column on screen */
unsigned off; /* offset in ScreenLines/ScreenAttrs */
int c = 0; /* init for GCC */
long vcol = 0; /* virtual column (for tabs) */
int col = 0; // visual column on screen
unsigned off; // offset in ScreenLines/ScreenAttrs
int c = 0; // init for GCC
long vcol = 0; // virtual column (for tabs)
long vcol_sbr = -1; // virtual column after showbreak
long vcol_prev = -1; /* "vcol" of previous character */
char_u *line; /* current line */
char_u *ptr; /* current position in "line" */
int row; /* row in the window, excl w_winrow */
int screen_row; /* row on the screen, incl w_winrow */
long vcol_prev = -1; // "vcol" of previous character
char_u *line; // current line
char_u *ptr; // current position in "line"
int row; // row in the window, excl w_winrow
int screen_row; // row on the screen, incl w_winrow
char_u extra[18]; /* line number and 'fdc' must fit in here */
int n_extra = 0; /* number of extra chars */
@ -2195,7 +2200,7 @@ win_line (
int change_start = MAXCOL; /* first col of changed area */
int change_end = -1; /* last col of changed area */
colnr_T trailcol = MAXCOL; /* start of trailing spaces */
int need_showbreak = FALSE;
int need_showbreak = false; // overlong line, skip first x chars
int line_attr = 0; /* attribute for the whole line */
matchitem_T *cur; /* points to the match list */
match_T *shl; /* points to search_hl or a match */
@ -2522,8 +2527,12 @@ win_line (
if (vcol > v) {
vcol -= c;
ptr = prev_ptr;
// If the character fits on the screen, don't need to skip it.
// Except for a TAB.
if (((*mb_ptr2cells)(ptr) >= c || *ptr == TAB) && col == 0) {
n_skip = v - vcol;
}
}
/*
* Adjust for when the inverted text is before the screen,
@ -2705,11 +2714,14 @@ win_line (
draw_state = WL_FOLD;
if (fdc > 0) {
// Draw the 'foldcolumn'.
fill_foldcolumn(extra, wp, false, lnum);
// Draw the 'foldcolumn'. Allocate a buffer, "extra" may
// already be in use.
xfree(p_extra_free);
p_extra_free = xmalloc(12 + 1);
fill_foldcolumn(p_extra_free, wp, false, lnum);
n_extra = fdc;
p_extra = extra;
p_extra[n_extra] = NUL;
p_extra_free[n_extra] = NUL;
p_extra = p_extra_free;
c_extra = NUL;
char_attr = win_hl_attr(wp, HLF_FC);
}
@ -2805,8 +2817,10 @@ win_line (
// draw 'breakindent': indent wrapped text accodringly
if (draw_state == WL_BRI - 1 && n_extra == 0) {
draw_state = WL_BRI;
if (wp->w_p_bri && row != startrow && filler_lines == 0) {
char_attr = wp->w_hl_attr_normal; // was: hl_attr(HLF_AT);
// if need_showbreak is set, breakindent also applies
if (wp->w_p_bri && (row != startrow || need_showbreak)
&& filler_lines == 0) {
char_attr = wp->w_hl_attr_normal;
if (diff_hlf != (hlf_T)0) {
char_attr = win_hl_attr(wp, diff_hlf);
@ -3510,6 +3524,7 @@ win_line (
p = xmalloc(len + 1);
memset(p, ' ', len);
p[len] = NUL;
xfree(p_extra_free);
p_extra_free = p;
for (i = 0; i < tab_len; i++) {
mb_char2bytes(lcs_tab2, p);
@ -3625,6 +3640,7 @@ win_line (
memset(p, ' ', n_extra);
STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
p[n_extra] = NUL;
xfree(p_extra_free);
p_extra_free = p_extra = p;
} else {
n_extra = byte2cells(c) - 1;
@ -4298,6 +4314,7 @@ win_line (
cap_col = 0;
}
xfree(p_extra_free);
return row;
}

View File

@ -0,0 +1,298 @@
" Test for breakindent
"
" Note: if you get strange failures when adding new tests, it might be that
" while the test is run, the breakindent cacheing gets in its way.
" It helps to change the tabstop setting and force a redraw (e.g. see
" Test_breakindent08())
if !exists('+breakindent')
finish
endif
source view_util.vim
let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
function s:screen_lines(lnum, width) abort
return ScreenLines([a:lnum, a:lnum + 2], a:width)
endfunction
function! s:compare_lines(expect, actual)
call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
endfunction
function s:test_windows(...)
call NewWindow(10, 20)
setl ts=4 sw=4 sts=4 breakindent
put =s:input
exe get(a:000, 0, '')
endfunction
function s:close_windows(...)
call CloseWindow()
exe get(a:000, 0, '')
endfunction
function Test_breakindent01()
" simple breakindent test
call s:test_windows('setl briopt=min:0')
let lines=s:screen_lines(line('.'),8)
let expect=[
\ " abcd",
\ " qrst",
\ " GHIJ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
function Test_breakindent02()
" simple breakindent test with showbreak set
call s:test_windows('setl briopt=min:0 sbr=>>')
let lines=s:screen_lines(line('.'),8)
let expect=[
\ " abcd",
\ " >>qr",
\ " >>EF",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set sbr=')
endfunction
function Test_breakindent03()
" simple breakindent test with showbreak set and briopt including sbr
call s:test_windows('setl briopt=sbr,min:0 sbr=++')
let lines=s:screen_lines(line('.'),8)
let expect=[
\ " abcd",
\ "++ qrst",
\ "++ GHIJ",
\ ]
call s:compare_lines(expect, lines)
" clean up
call s:close_windows('set sbr=')
endfunction
function Test_breakindent04()
" breakindent set with min width 18
call s:test_windows('setl sbr= briopt=min:18')
let lines=s:screen_lines(line('.'),8)
let expect=[
\ " abcd",
\ " qrstuv",
\ " IJKLMN",
\ ]
call s:compare_lines(expect, lines)
" clean up
call s:close_windows('set sbr=')
endfunction
function Test_breakindent05()
" breakindent set and shift by 2
call s:test_windows('setl briopt=shift:2,min:0')
let lines=s:screen_lines(line('.'),8)
let expect=[
\ " abcd",
\ " qr",
\ " EF",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
function Test_breakindent06()
" breakindent set and shift by -1
call s:test_windows('setl briopt=shift:-1,min:0')
let lines=s:screen_lines(line('.'),8)
let expect=[
\ " abcd",
\ " qrstu",
\ " HIJKL",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
function Test_breakindent07()
" breakindent set and shift by 1, Number set sbr=? and briopt:sbr
call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n')
let lines=s:screen_lines(line('.'),10)
let expect=[
\ " 2 ab",
\ "? m",
\ "? x",
\ ]
call s:compare_lines(expect, lines)
" clean up
call s:close_windows('set sbr= cpo-=n')
endfunction
function Test_breakindent07a()
" breakindent set and shift by 1, Number set sbr=? and briopt:sbr
call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4')
let lines=s:screen_lines(line('.'),10)
let expect=[
\ " 2 ab",
\ " ? m",
\ " ? x",
\ ]
call s:compare_lines(expect, lines)
" clean up
call s:close_windows('set sbr=')
endfunction
function Test_breakindent08()
" breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4')
" make sure, cache is invalidated!
set ts=8
redraw!
set ts=4
redraw!
let lines=s:screen_lines(line('.'),10)
let expect=[
\ " 2 ^Iabcd",
\ "# opq",
\ "# BCD",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set sbr= cpo-=n')
endfunction
function Test_breakindent08a()
" breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list')
let lines=s:screen_lines(line('.'),10)
let expect=[
\ " 2 ^Iabcd",
\ " # opq",
\ " # BCD",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set sbr=')
endfunction
function Test_breakindent09()
" breakindent set and shift by 1, Number and list set sbr=#
call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list')
let lines=s:screen_lines(line('.'),10)
let expect=[
\ " 2 ^Iabcd",
\ " #op",
\ " #AB",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set sbr=')
endfunction
function Test_breakindent10()
" breakindent set, Number set sbr=~
call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0')
" make sure, cache is invalidated!
set ts=8
redraw!
set ts=4
redraw!
let lines=s:screen_lines(line('.'),10)
let expect=[
\ " 2 ab",
\ "~ mn",
\ "~ yz",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set sbr= cpo-=n')
endfunction
function Test_breakindent11()
" test strdisplaywidth()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
let text=getline(2)
let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
call assert_equal(width, strdisplaywidth(text))
call s:close_windows('set sbr=')
endfunction
function Test_breakindent12()
" test breakindent with long indent
let s:input="\t\t\t\t\t{"
call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-')
let lines=s:screen_lines(2,16)
let expect=[
\ " 2 >--->--->--->",
\ " ---{ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set nuw=4 listchars=')
endfunction
function Test_breakindent13()
let s:input=""
call s:test_windows('setl breakindent briopt=min:10 ts=8')
vert resize 20
call setline(1, [" a\tb\tc\td\te", " z y x w v"])
1
norm! fbgj"ayl
2
norm! fygj"byl
call assert_equal('d', @a)
call assert_equal('w', @b)
call s:close_windows()
endfunction
function Test_breakindent14()
let s:input=""
call s:test_windows('setl breakindent briopt= ts=8')
vert resize 30
norm! 3a1234567890
norm! a abcde
exec "norm! 0\<C-V>tex"
let lines=s:screen_lines(line('.'),8)
let expect=[
\ "e ",
\ "~ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
function Test_breakindent15()
let s:input=""
call s:test_windows('setl breakindent briopt= ts=8 sw=8')
vert resize 30
norm! 4a1234567890
exe "normal! >>\<C-V>3f0x"
let lines=s:screen_lines(line('.'),20)
let expect=[
\ " 1234567890 ",
\ "~ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
function Test_breakindent16()
" Check that overlong lines are indented correctly.
let s:input=""
call s:test_windows('setl breakindent briopt=min:0 ts=4')
call setline(1, "\t".repeat("1234567890", 10))
resize 6
norm! 1gg$
redraw!
let lines=s:screen_lines(1,10)
let expect=[
\ " 789012",
\ " 345678",
\ " 901234",
\ ]
call s:compare_lines(expect, lines)
let lines=s:screen_lines(4,10)
let expect=[
\ " 567890",
\ " 123456",
\ " 7890 ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction

View File

@ -0,0 +1,71 @@
" Test for displaying stuff
" Nvim: `:set term` is not supported.
" if !has('gui_running') && has('unix')
" set term=ansi
" endif
source view_util.vim
func! Test_display_foldcolumn()
if !has("folding")
return
endif
new
vnew
vert resize 25
call assert_equal(25, winwidth(winnr()))
set isprint=@
1put='e more noise blah blah‚ more stuff here'
let expect = [
\ "e more noise blah blah<82",
\ "> more stuff here "
\ ]
call cursor(2, 1)
norm! zt
let lines=ScreenLines([1,2], winwidth(0))
call assert_equal(expect, lines)
set fdc=2
let lines=ScreenLines([1,2], winwidth(0))
let expect = [
\ " e more noise blah blah<",
\ " 82> more stuff here "
\ ]
call assert_equal(expect, lines)
quit!
quit!
endfunc
func! Test_display_foldtext_mbyte()
if !has("folding") || !has("multi_byte")
return
endif
call NewWindow(10, 40)
call append(0, range(1,20))
exe "set foldmethod=manual foldtext=foldtext() fillchars=fold:\u2500,vert:\u2502 fdc=2"
call cursor(2, 1)
norm! zf13G
let lines=ScreenLines([1,3], winwidth(0)+1)
let expect=[
\ " 1 \u2502",
\ "+ +-- 12 lines: 2". repeat("\u2500", 23). "\u2502",
\ " 14 \u2502",
\ ]
call assert_equal(expect, lines)
set fillchars=fold:-,vert:\|
let lines=ScreenLines([1,3], winwidth(0)+1)
let expect=[
\ " 1 |",
\ "+ +-- 12 lines: 2". repeat("-", 23). "|",
\ " 14 |",
\ ]
call assert_equal(expect, lines)
set foldtext& fillchars& foldmethod& fdc&
bw!
endfunc

View File

@ -0,0 +1,235 @@
" Test for linebreak and list option (non-utf8)
set encoding=latin1
scriptencoding latin1
if !exists("+linebreak") || !has("conceal")
finish
endif
source view_util.vim
function s:screen_lines(lnum, width) abort
return ScreenLines(a:lnum, a:width)
endfunction
function! s:compare_lines(expect, actual)
call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
endfunction
function s:test_windows(...)
call NewWindow(10, 20)
setl ts=8 sw=4 sts=4 linebreak sbr= wrap
exe get(a:000, 0, '')
endfunction
function s:close_windows(...)
call CloseWindow()
exe get(a:000, 0, '')
endfunction
func Test_set_linebreak()
call s:test_windows('setl ts=4 sbr=+')
call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP ")
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ " abcdef ",
\ "+hijklmn ",
\ "+pqrstuvwxyz_1060ABC",
\ "+DEFGHIJKLMNOP ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_linebreak_with_list()
call s:test_windows('setl ts=4 sbr=+ list listchars=')
call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP ")
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "^Iabcdef hijklmn^I ",
\ "+pqrstuvwxyz_1060ABC",
\ "+DEFGHIJKLMNOP ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_linebreak_with_nolist()
call s:test_windows('setl ts=4 sbr=+ nolist')
call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP ")
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ " abcdef ",
\ "+hijklmn ",
\ "+pqrstuvwxyz_1060ABC",
\ "+DEFGHIJKLMNOP ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_should_break()
call s:test_windows('setl sbr=+ nolist')
call setline(1, "1\t" . repeat('a', winwidth(0)-2))
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "1 ",
\ "+aaaaaaaaaaaaaaaaaa ",
\ "~ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_linebreak_with_conceal()
call s:test_windows('setl cpo&vim sbr=+ list conceallevel=2 concealcursor=nv listchars=tab:ab')
call setline(1, "_S_\t bla")
syn match ConcealVar contained /_/ conceal
syn match All /.*/ contains=ConcealVar
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "Sabbbbbb bla ",
\ "~ ",
\ "~ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_virtual_block()
call s:test_windows('setl sbr=+')
call setline(1, [
\ "REMOVE: this not",
\ "REMOVE: aaaaaaaaaaaaa",
\ ])
exe "norm! 1/^REMOVE:"
exe "norm! 0\<C-V>jf x"
$put
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "this not ",
\ "aaaaaaaaaaaaa ",
\ "REMOVE: ",
\ "REMOVE: ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_virtual_block_and_vbA()
call s:test_windows()
call setline(1, "long line: " . repeat("foobar ", 40) . "TARGET at end")
exe "norm! $3B\<C-v>eAx\<Esc>"
let lines = s:screen_lines([1, 10], winwidth(0))
let expect = [
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar foobar ",
\ "foobar TARGETx at ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_virtual_char_and_block()
call s:test_windows()
call setline(1, "1111-1111-1111-11-1111-1111-1111")
exe "norm! 0f-lv3lc2222\<Esc>bgj."
let lines = s:screen_lines([1, 2], winwidth(0))
let expect = [
\ "1111-2222-1111-11- ",
\ "1111-2222-1111 ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_undo_after_block_visual()
call s:test_windows()
call setline(1, ["aaa", "aaa", "a"])
exe "norm! gg\<C-V>2j~e."
let lines = s:screen_lines([1, 3], winwidth(0))
let expect = [
\ "AaA ",
\ "AaA ",
\ "A ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_norm_after_block_visual()
call s:test_windows()
call setline(1, ["abcd{ef", "ghijklm", "no}pgrs"])
exe "norm! ggf{\<C-V>\<C-V>c%"
let lines = s:screen_lines([1, 3], winwidth(0))
let expect = [
\ "abcdpgrs ",
\ "~ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_block_replace_after_wrapping()
call s:test_windows()
call setline(1, repeat("a", 150))
exe "norm! 0yypk147|\<C-V>jr0"
call assert_equal(repeat("a", 146) . "0aaa", getline(1))
call assert_equal(repeat("a", 146) . "0aaa", getline(2))
let lines = s:screen_lines([1, 10], winwidth(0))
let expect = [
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aaaaaa0aaa ",
\ "@ ",
\ "@ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_list_with_listchars()
call s:test_windows('setl list listchars=space:_,trail:-,tab:>-,eol:$')
call setline(1, "a aaaaaaaaaaaaaaaaaaaaaa\ta ")
let lines = s:screen_lines([1, 3], winwidth(0))
let expect = [
\ "a_ ",
\ "aaaaaaaaaaaaaaaaaaaa",
\ "aa>-----a-$ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_list_with_tab_and_skipping_first_chars()
call s:test_windows('setl list listchars=tab:>- ts=70 nowrap')
call setline(1, ["iiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa"])
call cursor(4,64)
norm! 2zl
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "---------------aaaaa",
\ "---------------aaaaa",
\ "---------------aaaaa",
\ "iiiiiiiii>-----aaaaa",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfu

View File

@ -0,0 +1,229 @@
" Test for linebreak and list option in utf-8 mode
set encoding=utf-8
scriptencoding utf-8
if !exists("+linebreak") || !has("conceal") || !has("signs")
finish
endif
source view_util.vim
function s:screen_lines(lnum, width) abort
return ScreenLines(a:lnum, a:width)
endfunction
function! s:compare_lines(expect, actual)
call assert_equal(a:expect, a:actual)
endfunction
function s:screen_attr(lnum, chars, ...) abort
let line = getline(a:lnum)
let attr = []
let prefix = get(a:000, 0, 0)
for i in range(a:chars[0], a:chars[1])
let scol = strdisplaywidth(strcharpart(line, 0, i-1)) + 1
let attr += [screenattr(a:lnum, scol + prefix)]
endfor
return attr
endfunction
function s:test_windows(...)
call NewWindow(10, 20)
setl ts=4 sw=4 sts=4 linebreak sbr=+ wrap
exe get(a:000, 0, '')
endfunction
function s:close_windows(...)
call CloseWindow()
exe get(a:000, 0, '')
endfunction
func Test_linebreak_with_fancy_listchars()
call s:test_windows("setl list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6")
call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP ")
redraw!
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "▕———abcdef ",
\ "+hijklmn▕——— ",
\ "+pqrstuvwxyz␣1060ABC",
\ "+DEFGHIJKLMNOPˑ¶ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_nolinebreak_with_list()
call s:test_windows("setl nolinebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6")
call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP ")
redraw!
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ "▕———abcdef hijklmn▕—",
\ "+pqrstuvwxyz␣1060ABC",
\ "+DEFGHIJKLMNOPˑ¶ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_linebreak_with_nolist()
call s:test_windows('setl nolist')
call setline(1, "\t*mask = nil;")
redraw!
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
\ " *mask = nil; ",
\ "~ ",
\ "~ ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_list_and_concealing1()
call s:test_windows('setl list listchars=tab:>- cole=1')
call setline(1, [
\ "#define ABCDE\t\t1",
\ "#define ABCDEF\t\t1",
\ "#define ABCDEFG\t\t1",
\ "#define ABCDEFGH\t1",
\ "#define MSG_MODE_FILE\t\t\t1",
\ "#define MSG_MODE_CONSOLE\t\t2",
\ "#define MSG_MODE_FILE_AND_CONSOLE\t3",
\ "#define MSG_MODE_FILE_THEN_CONSOLE\t4",
\ ])
vert resize 40
syn match Conceal conceal cchar=>'AB\|MSG_MODE'
redraw!
let lines = s:screen_lines([1, 7], winwidth(0))
let expect = [
\ "#define ABCDE>-->---1 ",
\ "#define >CDEF>-->---1 ",
\ "#define >CDEFG>->---1 ",
\ "#define >CDEFGH>----1 ",
\ "#define >_FILE>--------->--->---1 ",
\ "#define >_CONSOLE>---------->---2 ",
\ "#define >_FILE_AND_CONSOLE>---------3 ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_list_and_concealing2()
call s:test_windows('setl nowrap ts=2 list listchars=tab:>- cole=2 concealcursor=n')
call setline(1, "bbeeeeee\t\t;\tsome text")
vert resize 40
syn clear
syn match meaning /;\s*\zs.*/
syn match hasword /^\x\{8}/ contains=word
syn match word /\<\x\{8}\>/ contains=beginword,endword contained
syn match beginword /\<\x\x/ contained conceal
syn match endword /\x\{6}\>/ contained
hi meaning guibg=blue
hi beginword guibg=green
hi endword guibg=red
redraw!
let lines = s:screen_lines([1, 1], winwidth(0))
let expect = [
\ "eeeeee>--->-;>some text ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_screenattr_for_comment()
call s:test_windows("setl ft=c ts=7 list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6")
call setline(1, " /*\t\t and some more */")
norm! gg0
syntax on
hi SpecialKey term=underline ctermfg=red guifg=red
redraw!
let line = getline(1)
let attr = s:screen_attr(1, [1, 6])
call assert_notequal(attr[0], attr[1])
call assert_notequal(attr[1], attr[3])
call assert_notequal(attr[3], attr[5])
call s:close_windows()
endfunc
func Test_visual_block_and_selection_exclusive()
call s:test_windows('setl selection=exclusive')
call setline(1, "long line: " . repeat("foobar ", 40) . "TARGETÃ' at end")
exe "norm! $3B\<C-v>eAx\<Esc>"
let lines = s:screen_lines([1, 10], winwidth(0))
let expect = [
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar foobar ",
\ "+foobar TARGETÃx' ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_multibyte_sign_and_colorcolumn()
call s:test_windows("setl nolinebreak cc=3 list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6")
call setline(1, ["", "a b c", "a b c"])
exe "sign define foo text=\uff0b"
exe "sign place 1 name=foo line=2 buffer=" . bufnr('%')
redraw!
norm! ggj0
let signwidth = strdisplaywidth("\uff0b")
let attr1 = s:screen_attr(2, [1, 3], signwidth)
let attr2 = s:screen_attr(3, [1, 3], signwidth)
call assert_equal(attr1[0], attr2[0])
call assert_equal(attr1[1], attr2[1])
call assert_equal(attr1[2], attr2[2])
let lines = s:screen_lines([1, 3], winwidth(0))
let expect = [
\ " ¶ ",
\ "a b c¶ ",
\ " a b c¶ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_chinese_char_on_wrap_column()
call s:test_windows("setl nolbr wrap sbr=")
syntax off
call setline(1, [
\ 'aaaaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'aaaaaaaaaaaaaaaaa中'.
\ 'hello'])
call cursor(1,1)
norm! $
redraw!
let expect=[
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中aaaaaaaaaaaaaaaaa>',
\ '中hello ']
let lines = s:screen_lines([1, 10], winwidth(0))
call s:compare_lines(expect, lines)
call s:close_windows()
endfu

View File

@ -0,0 +1,30 @@
" Functions about view shared by several tests
" ScreenLines(lnum, width) or
" ScreenLines([start, end], width)
function! ScreenLines(lnum, width) abort
redraw!
if type(a:lnum) == v:t_list
let start = a:lnum[0]
let end = a:lnum[1]
else
let start = a:lnum
let end = a:lnum
endif
let lines = []
for l in range(start, end)
let lines += [join(map(range(1, a:width), 'nr2char(screenchar(l, v:val))'), '')]
endfor
return lines
endfunction
function! NewWindow(height, width) abort
exe a:height . 'new'
exe a:width . 'vsp'
redraw!
endfunction
function! CloseWindow() abort
bw!
redraw!
endfunction

View File

@ -428,13 +428,13 @@ static const int included_patches[] = {
// 527,
// 526,
// 525,
// 524,
524,
// 523,
// 522,
// 521,
// 520,
// 519,
// 518,
518,
// 517,
// 516,
// 515,
@ -558,7 +558,7 @@ static const int included_patches[] = {
// 397,
// 396,
// 395,
// 394,
394,
393,
// 392,
// 391,
@ -641,7 +641,7 @@ static const int included_patches[] = {
// 314,
// 313,
// 312,
// 311,
311,
// 310,
// 309,
// 308,
@ -662,7 +662,7 @@ static const int included_patches[] = {
// 293,
// 292,
// 291,
// 290,
290,
// 289,
// 288 NA
// 287,
@ -717,7 +717,7 @@ static const int included_patches[] = {
// 238,
// 237,
// 236,
// 235,
235,
// 234,
// 233,
// 232 NA
@ -824,9 +824,9 @@ static const int included_patches[] = {
// 131,
// 130 NA
// 129 NA
// 128,
128,
127,
// 126,
126,
// 125,
124,
// 123 NA
@ -862,7 +862,7 @@ static const int included_patches[] = {
// 93 NA
// 92,
// 91,
// 90,
90,
// 89 NA
88,
// 87 NA