mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	Merge pull request #14634 from janlazo/vim-8.2.2880
vim-patch:8.2.{511,1689,1957,2880,2884}
			
			
This commit is contained in:
		@@ -982,12 +982,14 @@ static int check_external_diff(diffio_T *diffio)
 | 
			
		||||
          char_u linebuf[LBUFLEN];
 | 
			
		||||
 | 
			
		||||
          for (;;) {
 | 
			
		||||
            // There must be a line that contains "1c1".
 | 
			
		||||
            // For normal diff there must be a line that contains
 | 
			
		||||
            // "1c1".  For unified diff "@@ -1 +1 @@".
 | 
			
		||||
            if (vim_fgets(linebuf, LBUFLEN, fd)) {
 | 
			
		||||
              break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (STRNCMP(linebuf, "1c1", 3) == 0) {
 | 
			
		||||
            if (STRNCMP(linebuf, "1c1", 3) == 0
 | 
			
		||||
                || STRNCMP(linebuf, "@@ -1 +1 @@", 11) == 0) {
 | 
			
		||||
              ok = kTrue;
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
 
 | 
			
		||||
@@ -4138,9 +4138,16 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
 | 
			
		||||
    // highlight the cursor position itself.
 | 
			
		||||
    // Also highlight the 'colorcolumn' if it is different than
 | 
			
		||||
    // 'cursorcolumn'
 | 
			
		||||
    // Also highlight the 'colorcolumn' if 'breakindent' and/or 'showbreak'
 | 
			
		||||
    // options are set
 | 
			
		||||
    vcol_save_attr = -1;
 | 
			
		||||
    if (draw_state == WL_LINE && !lnum_in_visual_area
 | 
			
		||||
        && search_attr == 0 && area_attr == 0) {
 | 
			
		||||
    if ((draw_state == WL_LINE
 | 
			
		||||
         || draw_state == WL_BRI
 | 
			
		||||
         || draw_state == WL_SBR)
 | 
			
		||||
        && !lnum_in_visual_area
 | 
			
		||||
        && search_attr == 0
 | 
			
		||||
        && area_attr == 0
 | 
			
		||||
        && filler_todo <= 0) {
 | 
			
		||||
      if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol
 | 
			
		||||
          && lnum != wp->w_cursor.lnum) {
 | 
			
		||||
        vcol_save_attr = char_attr;
 | 
			
		||||
 
 | 
			
		||||
@@ -179,7 +179,7 @@ endfunc
 | 
			
		||||
func s:WaitForCommon(expr, assert, timeout)
 | 
			
		||||
  " using reltime() is more accurate, but not always available
 | 
			
		||||
  let slept = 0
 | 
			
		||||
  if has('reltime')
 | 
			
		||||
  if exists('*reltimefloat')
 | 
			
		||||
    let start = reltime()
 | 
			
		||||
  endif
 | 
			
		||||
 | 
			
		||||
@@ -204,7 +204,7 @@ func s:WaitForCommon(expr, assert, timeout)
 | 
			
		||||
    endif
 | 
			
		||||
 | 
			
		||||
    sleep 10m
 | 
			
		||||
    if has('reltime')
 | 
			
		||||
    if exists('*reltimefloat')
 | 
			
		||||
      let slept = float2nr(reltimefloat(reltime(start)) * 1000)
 | 
			
		||||
    else
 | 
			
		||||
      let slept += 10
 | 
			
		||||
@@ -220,7 +220,7 @@ endfunc
 | 
			
		||||
" feeds key-input and resumes process. Return time waited in milliseconds.
 | 
			
		||||
" Without +timers it uses simply :sleep.
 | 
			
		||||
func Standby(msec)
 | 
			
		||||
  if has('timers')
 | 
			
		||||
  if has('timers') && exists('*reltimefloat')
 | 
			
		||||
    let start = reltime()
 | 
			
		||||
    let g:_standby_timer = timer_start(a:msec, function('s:feedkeys'))
 | 
			
		||||
    call getchar()
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ endfunc
 | 
			
		||||
 | 
			
		||||
func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    call CscopeSetupOrClean(1)
 | 
			
		||||
    " Test 0: E568: duplicate cscope database not added
 | 
			
		||||
    " Test: E568: duplicate cscope database not added
 | 
			
		||||
    try
 | 
			
		||||
      set nocscopeverbose
 | 
			
		||||
      cscope add Xcscope.out
 | 
			
		||||
@@ -33,44 +33,49 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    call assert_fails('cscope add', 'E560')
 | 
			
		||||
    call assert_fails('cscope add Xcscope.out', 'E568')
 | 
			
		||||
    call assert_fails('cscope add doesnotexist.out', 'E563')
 | 
			
		||||
    if has('unix')
 | 
			
		||||
      call assert_fails('cscope add /dev/null', 'E564:')
 | 
			
		||||
    endif
 | 
			
		||||
 | 
			
		||||
    " Test 1: Find this C-Symbol
 | 
			
		||||
    " Test: Find this C-Symbol
 | 
			
		||||
    for cmd in ['cs find s main', 'cs find 0 main']
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
      " Test 1.1 test where it moves the cursor
 | 
			
		||||
      " Test where it moves the cursor
 | 
			
		||||
      call assert_equal('main(void)', getline('.'))
 | 
			
		||||
      " Test 1.2 test the output of the :cs command
 | 
			
		||||
      " Test the output of the :cs command
 | 
			
		||||
      call assert_match('\n(1 of 1): <<main>> main(void )', a)
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 2: Find this definition
 | 
			
		||||
    for cmd in ['cs find g test_mf_hash', 'cs find 1 test_mf_hash']
 | 
			
		||||
    " Test: Find this definition
 | 
			
		||||
    for cmd in ['cs find g test_mf_hash',
 | 
			
		||||
          \     'cs find 1 test_mf_hash',
 | 
			
		||||
          \     'cs find 1   test_mf_hash'] " leading space ignored.
 | 
			
		||||
      exe cmd
 | 
			
		||||
      call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', '    static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1))
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 3: Find functions called by this function
 | 
			
		||||
    " Test: Find functions called by this function
 | 
			
		||||
    for cmd in ['cs find d test_mf_hash', 'cs find 2 test_mf_hash']
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
      call assert_match('\n(1 of 42): <<mf_hash_init>> mf_hash_init(&ht);', a)
 | 
			
		||||
      call assert_equal('    mf_hash_init(&ht);', getline('.'))
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 4: Find functions calling this function
 | 
			
		||||
    " Test: Find functions calling this function
 | 
			
		||||
    for cmd in ['cs find c test_mf_hash', 'cs find 3 test_mf_hash']
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
      call assert_match('\n(1 of 1): <<main>> test_mf_hash();', a)
 | 
			
		||||
      call assert_equal('    test_mf_hash();', getline('.'))
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 5: Find this text string
 | 
			
		||||
    " Test: Find this text string
 | 
			
		||||
    for cmd in ['cs find t Bram', 'cs find 4 Bram']
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
      call assert_match('(1 of 1): <<<unknown>>>  \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
 | 
			
		||||
      call assert_equal(' * VIM - Vi IMproved	by Bram Moolenaar', getline('.'))
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 6: Find this egrep pattern
 | 
			
		||||
    " Test: Find this egrep pattern
 | 
			
		||||
    " test all matches returned by cscope
 | 
			
		||||
    for cmd in ['cs find e ^\#includ.', 'cs find 6 ^\#includ.']
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
@@ -83,7 +88,7 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
      call assert_fails('cnext', 'E553:')
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 7: Find the same egrep pattern using lcscope this time.
 | 
			
		||||
    " Test: Find the same egrep pattern using lcscope this time.
 | 
			
		||||
    let a = execute('lcs find e ^\#includ.')
 | 
			
		||||
    call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a)
 | 
			
		||||
    call assert_equal('#include <assert.h>', getline('.'))
 | 
			
		||||
@@ -93,7 +98,7 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    call assert_equal('#include "memfile.c"', getline('.'))
 | 
			
		||||
    call assert_fails('lnext', 'E553:')
 | 
			
		||||
 | 
			
		||||
    " Test 8: Find this file
 | 
			
		||||
    " Test: Find this file
 | 
			
		||||
    for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c']
 | 
			
		||||
      enew
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
@@ -101,7 +106,7 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
      call assert_equal('Xmemfile_test.c', @%)
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 9: Find files #including this file
 | 
			
		||||
    " Test: Find files #including this file
 | 
			
		||||
    for cmd in ['cs find i assert.h', 'cs find 8 assert.h']
 | 
			
		||||
      enew
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
@@ -112,39 +117,42 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
      call assert_equal('#include <assert.h>', getline('.'))
 | 
			
		||||
    endfor
 | 
			
		||||
 | 
			
		||||
    " Test 10: Invalid find command
 | 
			
		||||
    " Test: Invalid find command
 | 
			
		||||
    call assert_fails('cs find', 'E560:')
 | 
			
		||||
    call assert_fails('cs find x', 'E560:')
 | 
			
		||||
 | 
			
		||||
    " Test 11: Find places where this symbol is assigned a value
 | 
			
		||||
    " this needs a cscope >= 15.8
 | 
			
		||||
    " unfortunately, Travis has cscope version 15.7
 | 
			
		||||
    let cscope_version = systemlist('cscope --version')[0]
 | 
			
		||||
    let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
 | 
			
		||||
    if cs_version >= 15.8
 | 
			
		||||
      for cmd in ['cs find a item', 'cs find 9 item']
 | 
			
		||||
        let a = execute(cmd)
 | 
			
		||||
        call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
 | 
			
		||||
        call assert_equal('	item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', getline('.'))
 | 
			
		||||
        cnext
 | 
			
		||||
        call assert_equal('	item = mf_hash_find(&ht, key);', getline('.'))
 | 
			
		||||
        cnext
 | 
			
		||||
        call assert_equal('	    item = mf_hash_find(&ht, key);', getline('.'))
 | 
			
		||||
        cnext
 | 
			
		||||
        call assert_equal('	item = mf_hash_find(&ht, key);', getline('.'))
 | 
			
		||||
      endfor
 | 
			
		||||
    if has('float')
 | 
			
		||||
      " Test: Find places where this symbol is assigned a value
 | 
			
		||||
      " this needs a cscope >= 15.8
 | 
			
		||||
      " unfortunately, Travis has cscope version 15.7
 | 
			
		||||
      let cscope_version = systemlist('cscope --version')[0]
 | 
			
		||||
      let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
 | 
			
		||||
      if cs_version >= 15.8
 | 
			
		||||
        for cmd in ['cs find a item', 'cs find 9 item']
 | 
			
		||||
          let a = execute(cmd)
 | 
			
		||||
          call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
 | 
			
		||||
          call assert_equal('	item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', getline('.'))
 | 
			
		||||
          cnext
 | 
			
		||||
          call assert_equal('	item = mf_hash_find(&ht, key);', getline('.'))
 | 
			
		||||
          cnext
 | 
			
		||||
          call assert_equal('	    item = mf_hash_find(&ht, key);', getline('.'))
 | 
			
		||||
          cnext
 | 
			
		||||
          call assert_equal('	item = mf_hash_find(&ht, key);', getline('.'))
 | 
			
		||||
        endfor
 | 
			
		||||
      endif
 | 
			
		||||
    endif
 | 
			
		||||
 | 
			
		||||
    " Test 12: leading whitespace is not removed for cscope find text
 | 
			
		||||
    " Test: leading whitespace is not removed for cscope find text
 | 
			
		||||
    let a = execute('cscope find t     test_mf_hash')
 | 
			
		||||
    call assert_equal(['', '(1 of 1): <<<unknown>>>     test_mf_hash();'], split(a, '\n', 1))
 | 
			
		||||
    call assert_equal('    test_mf_hash();', getline('.'))
 | 
			
		||||
 | 
			
		||||
    " Test 13: test with scscope
 | 
			
		||||
    " Test: test with scscope
 | 
			
		||||
    let a = execute('scs find t Bram')
 | 
			
		||||
    call assert_match('(1 of 1): <<<unknown>>>  \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
 | 
			
		||||
    call assert_equal(' * VIM - Vi IMproved	by Bram Moolenaar', getline('.'))
 | 
			
		||||
 | 
			
		||||
    " Test 14: cscope help
 | 
			
		||||
    " Test: cscope help
 | 
			
		||||
    for cmd in ['cs', 'cs help', 'cs xxx']
 | 
			
		||||
      let a = execute(cmd)
 | 
			
		||||
      call assert_match('^cscope commands:\n', a)
 | 
			
		||||
@@ -158,28 +166,35 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    let a = execute('scscope help')
 | 
			
		||||
    call assert_match('This cscope command does not support splitting the window\.', a)
 | 
			
		||||
 | 
			
		||||
    " Test 15: reset connections
 | 
			
		||||
    " Test: reset connections
 | 
			
		||||
    let a = execute('cscope reset')
 | 
			
		||||
    call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a)
 | 
			
		||||
    call assert_match('\nAll cscope databases reset', a)
 | 
			
		||||
 | 
			
		||||
    " Test 16: cscope show
 | 
			
		||||
    " Test: cscope show
 | 
			
		||||
    let a = execute('cscope show')
 | 
			
		||||
    call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
 | 
			
		||||
 | 
			
		||||
    " Test 17: cstag and 'csto' option
 | 
			
		||||
    " Test: cstag and 'csto' option
 | 
			
		||||
    set csto=0
 | 
			
		||||
    let a = execute('cstag TEST_COUNT')
 | 
			
		||||
    call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
 | 
			
		||||
    call assert_equal('#define TEST_COUNT 50000', getline('.'))
 | 
			
		||||
    call assert_fails('cstag DOES_NOT_EXIST', 'E257:')
 | 
			
		||||
    set csto=1
 | 
			
		||||
    let a = execute('cstag index_to_key')
 | 
			
		||||
    call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
 | 
			
		||||
    call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.'))
 | 
			
		||||
    call assert_fails('cstag xxx', 'E257:')
 | 
			
		||||
    call assert_fails('cstag DOES_NOT_EXIST', 'E257:')
 | 
			
		||||
    call assert_fails('cstag', 'E562:')
 | 
			
		||||
    let save_tags = &tags
 | 
			
		||||
    set tags=
 | 
			
		||||
    call assert_fails('cstag DOES_NOT_EXIST', 'E257:')
 | 
			
		||||
    let a = execute('cstag index_to_key')
 | 
			
		||||
    call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
 | 
			
		||||
    let &tags = save_tags
 | 
			
		||||
 | 
			
		||||
    " Test 18: 'cst' option
 | 
			
		||||
    " Test: 'cst' option
 | 
			
		||||
    set nocst
 | 
			
		||||
    call assert_fails('tag TEST_COUNT', 'E426:')
 | 
			
		||||
    set cst
 | 
			
		||||
@@ -189,12 +204,28 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    let a = execute('tags')
 | 
			
		||||
    call assert_match('1  1 TEST_COUNT\s\+\d\+\s\+#define index_to_key', a)
 | 
			
		||||
 | 
			
		||||
    " Test 19: this should trigger call to cs_print_tags()
 | 
			
		||||
    " Test: 'cscoperelative'
 | 
			
		||||
    call mkdir('Xcscoperelative')
 | 
			
		||||
    cd Xcscoperelative
 | 
			
		||||
    let a = execute('cs find g test_mf_hash')
 | 
			
		||||
    call assert_notequal('test_mf_hash(void)', getline('.'))
 | 
			
		||||
    set cscoperelative
 | 
			
		||||
    let a = execute('cs find g test_mf_hash')
 | 
			
		||||
    call assert_equal('test_mf_hash(void)', getline('.'))
 | 
			
		||||
    set nocscoperelative
 | 
			
		||||
    cd ..
 | 
			
		||||
    call delete('Xcscoperelative', 'd')
 | 
			
		||||
 | 
			
		||||
    " Test: E259: no match found
 | 
			
		||||
    call assert_fails('cscope find g DOES_NOT_EXIST', 'E259:')
 | 
			
		||||
 | 
			
		||||
    " Test: this should trigger call to cs_print_tags()
 | 
			
		||||
    " Unclear how to check result though, we just exercise the code.
 | 
			
		||||
    set cst cscopequickfix=s0
 | 
			
		||||
    call feedkeys(":cs find s main\<CR>", 't')
 | 
			
		||||
 | 
			
		||||
    " Test 20: cscope kill
 | 
			
		||||
    " Test: cscope kill
 | 
			
		||||
    call assert_fails('cscope kill', 'E560:')
 | 
			
		||||
    call assert_fails('cscope kill 2', 'E261:')
 | 
			
		||||
    call assert_fails('cscope kill xxx', 'E261:')
 | 
			
		||||
 | 
			
		||||
@@ -211,20 +242,20 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    let a = execute('cscope kill -1')
 | 
			
		||||
    call assert_equal('', a)
 | 
			
		||||
 | 
			
		||||
    " Test 21: 'csprg' option
 | 
			
		||||
    " Test: 'csprg' option
 | 
			
		||||
    call assert_equal('cscope', &csprg)
 | 
			
		||||
    set csprg=doesnotexist
 | 
			
		||||
    call assert_fails('cscope add Xcscope2.out', 'E609:')
 | 
			
		||||
    set csprg=cscope
 | 
			
		||||
 | 
			
		||||
    " Test 22: multiple cscope connections
 | 
			
		||||
    " Test: multiple cscope connections
 | 
			
		||||
    cscope add Xcscope.out
 | 
			
		||||
    cscope add Xcscope2.out . -C
 | 
			
		||||
    let a = execute('cscope show')
 | 
			
		||||
    call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
 | 
			
		||||
    call assert_match('\n 1 \d\+.*Xcscope2.out\s*\.', a)
 | 
			
		||||
 | 
			
		||||
    " Test 23: test Ex command line completion
 | 
			
		||||
    " Test: test Ex command line completion
 | 
			
		||||
    call feedkeys(":cs \<C-A>\<C-B>\"\<CR>", 'tx')
 | 
			
		||||
    call assert_equal('"cs add find help kill reset show', @:)
 | 
			
		||||
 | 
			
		||||
@@ -240,19 +271,26 @@ func Test_cscopeWithCscopeConnections()
 | 
			
		||||
    call feedkeys(":cs add Xcscope\<C-A>\<C-B>\"\<CR>", 'tx')
 | 
			
		||||
    call assert_equal('"cs add Xcscope.out Xcscope2.out', @:)
 | 
			
		||||
 | 
			
		||||
    " Test 24: cscope_connection()
 | 
			
		||||
    " Test: cscope_connection()
 | 
			
		||||
    call assert_equal(cscope_connection(), 1)
 | 
			
		||||
    call assert_equal(cscope_connection(0, 'out'), 1)
 | 
			
		||||
    call assert_equal(cscope_connection(0, 'xxx'), 1)
 | 
			
		||||
 | 
			
		||||
    call assert_equal(cscope_connection(1, 'out'), 1)
 | 
			
		||||
    call assert_equal(cscope_connection(1, 'xxx'), 0)
 | 
			
		||||
 | 
			
		||||
    call assert_equal(cscope_connection(2, 'out'), 0)
 | 
			
		||||
    call assert_equal(cscope_connection(2, getcwd() .. '/Xcscope.out', 1), 1)
 | 
			
		||||
 | 
			
		||||
    call assert_equal(cscope_connection(3, 'xxx', '..'), 0)
 | 
			
		||||
    call assert_equal(cscope_connection(3, 'out', 'xxx'), 0)
 | 
			
		||||
    call assert_equal(cscope_connection(3, 'out', '.'), 1)
 | 
			
		||||
 | 
			
		||||
    call assert_equal(cscope_connection(4, 'out', '.'), 0)
 | 
			
		||||
 | 
			
		||||
    " CleanUp
 | 
			
		||||
    call assert_equal(cscope_connection(5, 'out'), 0)
 | 
			
		||||
    call assert_equal(cscope_connection(-1, 'out'), 0)
 | 
			
		||||
 | 
			
		||||
    call CscopeSetupOrClean(0)
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -802,6 +802,7 @@ func VerifyBoth(buf, dumpfile, extra)
 | 
			
		||||
 | 
			
		||||
  " also test unified diff
 | 
			
		||||
  call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:")
 | 
			
		||||
  call term_sendkeys(a:buf, ":redraw!\<CR>:")
 | 
			
		||||
  call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified')
 | 
			
		||||
  call term_sendkeys(a:buf, ":call StopUnified()\<CR>:")
 | 
			
		||||
endfunc
 | 
			
		||||
@@ -823,10 +824,11 @@ func Test_diff_screen()
 | 
			
		||||
      func UnifiedDiffExpr()
 | 
			
		||||
        " Prepend some text to check diff type detection
 | 
			
		||||
        call writefile(['warning', '  message'], v:fname_out)
 | 
			
		||||
        silent exe '!diff -u ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
 | 
			
		||||
        silent exe '!diff -U0 ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
 | 
			
		||||
      endfunc
 | 
			
		||||
      func SetupUnified()
 | 
			
		||||
        set diffexpr=UnifiedDiffExpr()
 | 
			
		||||
        diffupdate
 | 
			
		||||
      endfunc
 | 
			
		||||
      func StopUnified()
 | 
			
		||||
        set diffexpr=
 | 
			
		||||
@@ -1146,4 +1148,38 @@ func Test_diff_and_scroll()
 | 
			
		||||
  set ls&
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_diff_filler_cursorcolumn()
 | 
			
		||||
  CheckScreendump
 | 
			
		||||
 | 
			
		||||
  let content =<< trim END
 | 
			
		||||
    call setline(1, ['aa', 'bb', 'cc'])
 | 
			
		||||
    vnew
 | 
			
		||||
    call setline(1, ['aa', 'cc'])
 | 
			
		||||
    windo diffthis
 | 
			
		||||
    wincmd p
 | 
			
		||||
    setlocal cursorcolumn foldcolumn=0
 | 
			
		||||
    norm! gg0
 | 
			
		||||
    redraw!
 | 
			
		||||
  END
 | 
			
		||||
  call writefile(content, 'Xtest_diff_cuc')
 | 
			
		||||
  let buf = RunVimInTerminal('-S Xtest_diff_cuc', {})
 | 
			
		||||
 | 
			
		||||
  call VerifyScreenDump(buf, 'Test_diff_cuc_01', {})
 | 
			
		||||
 | 
			
		||||
  call term_sendkeys(buf, "l")
 | 
			
		||||
  call term_sendkeys(buf, "\<C-l>")
 | 
			
		||||
  call VerifyScreenDump(buf, 'Test_diff_cuc_02', {})
 | 
			
		||||
  call term_sendkeys(buf, "0j")
 | 
			
		||||
  call term_sendkeys(buf, "\<C-l>")
 | 
			
		||||
  call VerifyScreenDump(buf, 'Test_diff_cuc_03', {})
 | 
			
		||||
  call term_sendkeys(buf, "l")
 | 
			
		||||
  call term_sendkeys(buf, "\<C-l>")
 | 
			
		||||
  call VerifyScreenDump(buf, 'Test_diff_cuc_04', {})
 | 
			
		||||
 | 
			
		||||
  " clean up
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
  call delete('Xtest_diff_cuc')
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
" vim: shiftwidth=2 sts=2 expandtab
 | 
			
		||||
 
 | 
			
		||||
@@ -28,12 +28,14 @@ func Test_empty()
 | 
			
		||||
  call assert_equal(0, empty(1))
 | 
			
		||||
  call assert_equal(0, empty(-1))
 | 
			
		||||
 | 
			
		||||
  call assert_equal(1, empty(0.0))
 | 
			
		||||
  call assert_equal(1, empty(-0.0))
 | 
			
		||||
  call assert_equal(0, empty(1.0))
 | 
			
		||||
  call assert_equal(0, empty(-1.0))
 | 
			
		||||
  call assert_equal(0, empty(1.0/0.0))
 | 
			
		||||
  call assert_equal(0, empty(0.0/0.0))
 | 
			
		||||
  if has('float')
 | 
			
		||||
    call assert_equal(1, empty(0.0))
 | 
			
		||||
    call assert_equal(1, empty(-0.0))
 | 
			
		||||
    call assert_equal(0, empty(1.0))
 | 
			
		||||
    call assert_equal(0, empty(-1.0))
 | 
			
		||||
    call assert_equal(0, empty(1.0/0.0))
 | 
			
		||||
    call assert_equal(0, empty(0.0/0.0))
 | 
			
		||||
  endif
 | 
			
		||||
 | 
			
		||||
  call assert_equal(1, empty([]))
 | 
			
		||||
  call assert_equal(0, empty(['a']))
 | 
			
		||||
@@ -115,7 +117,9 @@ func Test_strwidth()
 | 
			
		||||
    call assert_fails('call strwidth({->0})', 'E729:')
 | 
			
		||||
    call assert_fails('call strwidth([])', 'E730:')
 | 
			
		||||
    call assert_fails('call strwidth({})', 'E731:')
 | 
			
		||||
    call assert_fails('call strwidth(1.2)', 'E806:')
 | 
			
		||||
    if has('float')
 | 
			
		||||
      call assert_fails('call strwidth(1.2)', 'E806:')
 | 
			
		||||
    endif
 | 
			
		||||
  endfor
 | 
			
		||||
 | 
			
		||||
  set ambiwidth&
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
" Test glob2regpat()
 | 
			
		||||
 | 
			
		||||
func Test_glob2regpat_invalid()
 | 
			
		||||
  call assert_fails('call glob2regpat(1.33)', 'E806:')
 | 
			
		||||
  if has('float')
 | 
			
		||||
    call assert_fails('call glob2regpat(1.33)', 'E806:')
 | 
			
		||||
  endif
 | 
			
		||||
  call assert_fails('call glob2regpat("}")', 'E219:')
 | 
			
		||||
  call assert_fails('call glob2regpat("{")', 'E220:')
 | 
			
		||||
endfunc
 | 
			
		||||
 
 | 
			
		||||
@@ -595,6 +595,42 @@ func Test_cursorline_with_visualmode()
 | 
			
		||||
  call delete('Xtest_cursorline_with_visualmode')
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_colorcolumn_bri()
 | 
			
		||||
  CheckScreendump
 | 
			
		||||
 | 
			
		||||
  " check 'colorcolumn' when 'breakindent' is set
 | 
			
		||||
  let lines =<< trim END
 | 
			
		||||
	call setline(1, 'The quick brown fox jumped over the lazy dogs')
 | 
			
		||||
  END
 | 
			
		||||
  call writefile(lines, 'Xtest_colorcolumn_bri')
 | 
			
		||||
  let buf = RunVimInTerminal('-S Xtest_colorcolumn_bri', {'rows': 10,'columns': 40})
 | 
			
		||||
  call term_sendkeys(buf, ":set co=40 linebreak bri briopt=shift:2 cc=40,41,43\<CR>")
 | 
			
		||||
  call TermWait(buf)
 | 
			
		||||
  call VerifyScreenDump(buf, 'Test_colorcolumn_2', {})
 | 
			
		||||
 | 
			
		||||
  " clean up
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
  call delete('Xtest_colorcolumn_bri')
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_colorcolumn_sbr()
 | 
			
		||||
  CheckScreendump
 | 
			
		||||
 | 
			
		||||
  " check 'colorcolumn' when 'showbreak' is set
 | 
			
		||||
  let lines =<< trim END
 | 
			
		||||
	call setline(1, 'The quick brown fox jumped over the lazy dogs')
 | 
			
		||||
  END
 | 
			
		||||
  call writefile(lines, 'Xtest_colorcolumn_srb')
 | 
			
		||||
  let buf = RunVimInTerminal('-S Xtest_colorcolumn_srb', {'rows': 10,'columns': 40})
 | 
			
		||||
  call term_sendkeys(buf, ":set co=40 showbreak=+++>\\  cc=40,41,43\<CR>")
 | 
			
		||||
  call TermWait(buf)
 | 
			
		||||
  call VerifyScreenDump(buf, 'Test_colorcolumn_3', {})
 | 
			
		||||
 | 
			
		||||
  " clean up
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
  call delete('Xtest_colorcolumn_srb')
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
" This test must come before the Test_cursorline test, as it appears this
 | 
			
		||||
" defines the Normal highlighting group anyway.
 | 
			
		||||
func Test_1_highlight_Normalgroup_exists()
 | 
			
		||||
 
 | 
			
		||||
@@ -689,7 +689,9 @@ func Test_listdict_extend()
 | 
			
		||||
  let l = [1, 2, 3]
 | 
			
		||||
  call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:')
 | 
			
		||||
  call assert_fails("call extend(l, [4, 5, 6], -4)", 'E684:')
 | 
			
		||||
  call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:')
 | 
			
		||||
  if has('float')
 | 
			
		||||
    call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:')
 | 
			
		||||
  endif
 | 
			
		||||
 | 
			
		||||
  " Test extend() with dictionaries.
 | 
			
		||||
 | 
			
		||||
@@ -713,7 +715,9 @@ func Test_listdict_extend()
 | 
			
		||||
  let d = {'a': 'A', 'b': 'B'}
 | 
			
		||||
  call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
 | 
			
		||||
  call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:')
 | 
			
		||||
  call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E806:')
 | 
			
		||||
  if has('float')
 | 
			
		||||
    call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E806:')
 | 
			
		||||
  endif
 | 
			
		||||
  call assert_equal({'a': 'A', 'b': 'B'}, d)
 | 
			
		||||
 | 
			
		||||
  call assert_fails("call extend([1, 2], 1)", 'E712:')
 | 
			
		||||
 
 | 
			
		||||
@@ -105,7 +105,7 @@ fun InnerCall(funcref)
 | 
			
		||||
endfu
 | 
			
		||||
 | 
			
		||||
fun OuterCall()
 | 
			
		||||
  let opt = { 'func' : function('sin') }
 | 
			
		||||
  let opt = { 'func' : function('max') }
 | 
			
		||||
  call InnerCall(opt.func)
 | 
			
		||||
endfu
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
" Tests for regexp in latin1 encoding
 | 
			
		||||
 | 
			
		||||
" set encoding=latin1
 | 
			
		||||
scriptencoding latin1
 | 
			
		||||
 | 
			
		||||
source check.vim
 | 
			
		||||
 | 
			
		||||
func s:equivalence_test()
 | 
			
		||||
  let str = "AÀÁÂÃÄÅ B C D EÈÉÊË F G H IÌÍÎÏ J K L M NÑ OÒÓÔÕÖØ P Q R S T UÙÚÛÜ V W X YÝ Z aàáâãäå b c d eèéêë f g h iìíîï j k l m nñ oòóôõöø p q r s t uùúûü v w x yýÿ z"
 | 
			
		||||
  let groups = split(str)
 | 
			
		||||
@@ -42,9 +45,9 @@ func Test_range_with_newline()
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_pattern_compile_speed()
 | 
			
		||||
  if !exists('+spellcapcheck') || !has('reltime')
 | 
			
		||||
    return
 | 
			
		||||
  endif
 | 
			
		||||
  CheckOption spellcapcheck
 | 
			
		||||
  CheckFunction reltimefloat
 | 
			
		||||
 | 
			
		||||
  let start = reltime()
 | 
			
		||||
  " this used to be very slow, not it should be about a second
 | 
			
		||||
  set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
" Tests for the "sort()" function and for the ":sort" command.
 | 
			
		||||
 | 
			
		||||
source check.vim
 | 
			
		||||
 | 
			
		||||
func Compare1(a, b) abort
 | 
			
		||||
    call sort(range(3), 'Compare2')
 | 
			
		||||
    return a:a - a:b
 | 
			
		||||
@@ -59,6 +61,7 @@ func Test_sort_numbers()
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_sort_float()
 | 
			
		||||
  CheckFeature float
 | 
			
		||||
  call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f'))
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
@@ -68,6 +71,8 @@ func Test_sort_nested()
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_sort_default()
 | 
			
		||||
  CheckFeature float
 | 
			
		||||
 | 
			
		||||
  " docs say omitted, empty or zero argument sorts on string representation.
 | 
			
		||||
  call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"]))
 | 
			
		||||
  call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], ''))
 | 
			
		||||
@@ -1176,30 +1181,6 @@ func Test_sort_cmd()
 | 
			
		||||
	\    ]
 | 
			
		||||
	\ },
 | 
			
		||||
	\ {
 | 
			
		||||
	\    'name' : 'float',
 | 
			
		||||
	\    'cmd' : 'sort f',
 | 
			
		||||
	\    'input' : [
 | 
			
		||||
	\	'1.234',
 | 
			
		||||
	\	'0.88',
 | 
			
		||||
	\	'  +  123.456',
 | 
			
		||||
	\	'1.15e-6',
 | 
			
		||||
	\	'-1.1e3',
 | 
			
		||||
	\	'-1.01e3',
 | 
			
		||||
	\	'',
 | 
			
		||||
	\	''
 | 
			
		||||
	\    ],
 | 
			
		||||
	\    'expected' : [
 | 
			
		||||
	\	'',
 | 
			
		||||
	\	'',
 | 
			
		||||
	\	'-1.1e3',
 | 
			
		||||
	\	'-1.01e3',
 | 
			
		||||
	\	'1.15e-6',
 | 
			
		||||
	\	'0.88',
 | 
			
		||||
	\	'1.234',
 | 
			
		||||
	\	'  +  123.456'
 | 
			
		||||
	\    ]
 | 
			
		||||
	\ },
 | 
			
		||||
	\ {
 | 
			
		||||
	\    'name' : 'alphabetical, sorted input',
 | 
			
		||||
	\    'cmd' : 'sort',
 | 
			
		||||
	\    'input' : [
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
" Test behavior of boolean-like values.
 | 
			
		||||
 | 
			
		||||
source check.vim
 | 
			
		||||
 | 
			
		||||
" Test what is explained at ":help TRUE" and ":help FALSE".
 | 
			
		||||
func Test_if()
 | 
			
		||||
  if v:false
 | 
			
		||||
@@ -41,7 +43,9 @@ func Test_if()
 | 
			
		||||
  call assert_fails('if [1]', 'E745')
 | 
			
		||||
  call assert_fails('if {1: 1}', 'E728')
 | 
			
		||||
  call assert_fails('if function("string")', 'E703')
 | 
			
		||||
  call assert_fails('if 1.3")', 'E805')
 | 
			
		||||
  if has('float')
 | 
			
		||||
    call assert_fails('if 1.3")', 'E805')
 | 
			
		||||
  endif
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
function Try_arg_true_false(expr, false_val, true_val)
 | 
			
		||||
@@ -113,6 +117,7 @@ func Test_true_false_arg()
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
function Try_arg_non_zero(expr, false_val, true_val)
 | 
			
		||||
  CheckFeature float
 | 
			
		||||
  for v in ['v:false', '0', '[1]', '{2:3}', '3.4'] 
 | 
			
		||||
    let r = eval(substitute(a:expr, '%v%', v, ''))
 | 
			
		||||
    call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r)
 | 
			
		||||
 
 | 
			
		||||
@@ -113,9 +113,11 @@ func MakeBadFunc()
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_default_arg()
 | 
			
		||||
  call assert_equal(1.0, Log(10))
 | 
			
		||||
  call assert_equal(log(10), Log(10, exp(1)))
 | 
			
		||||
  call assert_fails("call Log(1,2,3)", 'E118')
 | 
			
		||||
  if has('float')
 | 
			
		||||
    call assert_equal(1.0, Log(10))
 | 
			
		||||
    call assert_equal(log(10), Log(10, exp(1)))
 | 
			
		||||
    call assert_fails("call Log(1,2,3)", 'E118')
 | 
			
		||||
  endif
 | 
			
		||||
 | 
			
		||||
  let res = Args(1)
 | 
			
		||||
  call assert_equal(res.mandatory, 1)
 | 
			
		||||
 
 | 
			
		||||
@@ -1271,8 +1271,10 @@ func Test_num64()
 | 
			
		||||
    call assert_equal(-9223372036854775807, -1 / 0)
 | 
			
		||||
    call assert_equal(-9223372036854775807 - 1,  0 / 0)
 | 
			
		||||
 | 
			
		||||
    call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
 | 
			
		||||
    call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
 | 
			
		||||
    if has('float')
 | 
			
		||||
      call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
 | 
			
		||||
      call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
 | 
			
		||||
    endif
 | 
			
		||||
 | 
			
		||||
    let rng = range(0xFFFFffff, 0x100000001)
 | 
			
		||||
    call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
 | 
			
		||||
@@ -1531,22 +1533,22 @@ func Test_compound_assignment_operators()
 | 
			
		||||
    call assert_equal('string', x)
 | 
			
		||||
    let x += 1
 | 
			
		||||
    call assert_equal(1, x)
 | 
			
		||||
    let x -= 1.5
 | 
			
		||||
    call assert_equal(-0.5, x)
 | 
			
		||||
 | 
			
		||||
    if has('float')
 | 
			
		||||
        " Test for float
 | 
			
		||||
        let x = 0.5
 | 
			
		||||
        let x += 4.5
 | 
			
		||||
        call assert_equal(5.0, x)
 | 
			
		||||
        let x -= 1.5
 | 
			
		||||
        call assert_equal(3.5, x)
 | 
			
		||||
        let x *= 3.0
 | 
			
		||||
        call assert_equal(10.5, x)
 | 
			
		||||
        let x /= 2.5
 | 
			
		||||
        call assert_equal(4.2, x)
 | 
			
		||||
        call assert_fails('let x %= 0.5', 'E734')
 | 
			
		||||
        call assert_fails('let x .= "f"', 'E734')
 | 
			
		||||
      " Test for float
 | 
			
		||||
      let x -= 1.5
 | 
			
		||||
      call assert_equal(-0.5, x)
 | 
			
		||||
      let x = 0.5
 | 
			
		||||
      let x += 4.5
 | 
			
		||||
      call assert_equal(5.0, x)
 | 
			
		||||
      let x -= 1.5
 | 
			
		||||
      call assert_equal(3.5, x)
 | 
			
		||||
      let x *= 3.0
 | 
			
		||||
      call assert_equal(10.5, x)
 | 
			
		||||
      let x /= 2.5
 | 
			
		||||
      call assert_equal(4.2, x)
 | 
			
		||||
      call assert_fails('let x %= 0.5', 'E734')
 | 
			
		||||
      call assert_fails('let x .= "f"', 'E734')
 | 
			
		||||
    endif
 | 
			
		||||
 | 
			
		||||
    " Test for environment variable
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user