diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-09 22:05:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-09 22:05:49 +0200 |
commit | 410e98a70bc00ea4bed51e55a8fe20e56a72c087 (patch) | |
tree | e0104f5f3a0f6974c686b3905e551fdcfc6a9f7f /src/testdir | |
parent | e5fbd7393067c279860598ac8359d1617b1082b9 (diff) |
patch 8.1.2019: 'cursorline' always highlights the whole linev8.1.2019
Problem: 'cursorline' always highlights the whole line.
Solution: Add 'cursorlineopt' to specify what is highlighted.
(closes #4693)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/Make_all.mak | 1 | ||||
-rw-r--r-- | src/testdir/gen_opt_test.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_cursorline.vim | 108 |
4 files changed, 111 insertions, 0 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index ee2a8f3f7e..68f26de162 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -92,6 +92,7 @@ NEW_TESTS = \ test_crypt \ test_cscope \ test_cursor_func \ + test_cursorline \ test_curswant \ test_debugger \ test_delete \ diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim index a8eca747da..437ad760c8 100644 --- a/src/testdir/gen_opt_test.vim +++ b/src/testdir/gen_opt_test.vim @@ -82,6 +82,7 @@ let test_values = { \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']], \ 'cryptmethod': [['', 'zip'], ['xxx']], \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']], + \ 'cursorlineopt': [['both', 'line', 'number'], ['', 'xxx', 'line,number']], \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']], \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx', 'algorithm:xxx', 'algorithm:']], \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']], diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index ab1dac49ae..e3ce1e123f 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -9,6 +9,7 @@ source test_cd.vim source test_changedtick.vim source test_compiler.vim source test_cursor_func.vim +source test_cursorline.vim source test_delete.vim source test_ex_equal.vim source test_ex_undo.vim diff --git a/src/testdir/test_cursorline.vim b/src/testdir/test_cursorline.vim new file mode 100644 index 0000000000..46fbd0cd64 --- /dev/null +++ b/src/testdir/test_cursorline.vim @@ -0,0 +1,108 @@ +" Test for cursorline and cursorlineopt +" +source view_util.vim +source check.vim + +function! s:screen_attr(lnum) abort + return map(range(1, 8), 'screenattr(a:lnum, v:val)') +endfunction + +function! s:test_windows(h, w) abort + call NewWindow(a:h, a:w) +endfunction + +function! s:close_windows() abort + call CloseWindow() +endfunction + +function! s:new_hi() abort + redir => save_hi + silent! hi CursorLineNr + redir END + let save_hi = join(split(substitute(save_hi, '\s*xxx\s*', ' ', ''), "\n"), '') + exe 'hi' save_hi 'ctermbg=0 guibg=Black' + return save_hi +endfunction + +func Test_cursorline_highlight1() + let save_hi = s:new_hi() + try + call s:test_windows(10, 20) + call setline(1, repeat(['aaaa'], 10)) + redraw + let attr01 = s:screen_attr(1) + call assert_equal(repeat([attr01[0]], 8), attr01) + + setl number numberwidth=4 + redraw + let attr11 = s:screen_attr(1) + call assert_equal(repeat([attr11[0]], 4), attr11[0:3]) + call assert_equal(repeat([attr11[4]], 4), attr11[4:7]) + call assert_notequal(attr11[0], attr11[4]) + + setl cursorline + redraw + let attr21 = s:screen_attr(1) + let attr22 = s:screen_attr(2) + call assert_equal(repeat([attr21[0]], 4), attr21[0:3]) + call assert_equal(repeat([attr21[4]], 4), attr21[4:7]) + call assert_equal(attr11, attr22) + call assert_notequal(attr22, attr21) + + setl nocursorline relativenumber + redraw + let attr31 = s:screen_attr(1) + call assert_equal(attr21[0:3], attr31[0:3]) + call assert_equal(attr11[4:7], attr31[4:7]) + + call s:close_windows() + finally + exe 'hi' save_hi + endtry +endfunc + +func Test_cursorline_highlight2() + CheckOption cursorlineopt + + let save_hi = s:new_hi() + try + call s:test_windows(10, 20) + call setline(1, repeat(['aaaa'], 10)) + redraw + let attr0 = s:screen_attr(1) + call assert_equal(repeat([attr0[0]], 8), attr0) + + setl number + redraw + let attr1 = s:screen_attr(1) + call assert_notequal(attr0[0:3], attr1[0:3]) + call assert_equal(attr0[0:3], attr1[4:7]) + + setl cursorline cursorlineopt=both + redraw + let attr2 = s:screen_attr(1) + call assert_notequal(attr1[0:3], attr2[0:3]) + call assert_notequal(attr1[4:7], attr2[4:7]) + + setl cursorlineopt=line + redraw + let attr3 = s:screen_attr(1) + call assert_equal(attr1[0:3], attr3[0:3]) + call assert_equal(attr2[4:7], attr3[4:7]) + + setl cursorlineopt=number + redraw + let attr4 = s:screen_attr(1) + call assert_equal(attr2[0:3], attr4[0:3]) + call assert_equal(attr1[4:7], attr4[4:7]) + + setl nonumber + redraw + let attr5 = s:screen_attr(1) + call assert_equal(attr0, attr5) + + call s:close_windows() + finally + exe 'hi' save_hi + endtry +endfunc |