mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	Merge pull request #19334 from zeertzjq/vim-8.2.0275
vim-patch:8.2.{0275,0293,5050}
			
			
This commit is contained in:
		@@ -5303,6 +5303,16 @@ void f_matchfuzzypos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
				
			|||||||
  do_fuzzymatch(argvars, rettv, true);
 | 
					  do_fuzzymatch(argvars, rettv, true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Get line "lnum" and copy it into "buf[LSIZE]".
 | 
				
			||||||
 | 
					/// The copy is made because the regexp may make the line invalid when using a
 | 
				
			||||||
 | 
					/// mark.
 | 
				
			||||||
 | 
					static char_u *get_line_and_copy(linenr_T lnum, char_u *buf)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  char_u *line = ml_get(lnum);
 | 
				
			||||||
 | 
					  STRLCPY(buf, line, LSIZE);
 | 
				
			||||||
 | 
					  return buf;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Find identifiers or defines in included files.
 | 
					/// Find identifiers or defines in included files.
 | 
				
			||||||
/// If p_ic && (compl_cont_status & CONT_SOL) then ptr must be in lowercase.
 | 
					/// If p_ic && (compl_cont_status & CONT_SOL) then ptr must be in lowercase.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
@@ -5399,7 +5409,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
 | 
				
			|||||||
  if (lnum > end_lnum) {                // do at least one line
 | 
					  if (lnum > end_lnum) {                // do at least one line
 | 
				
			||||||
    lnum = end_lnum;
 | 
					    lnum = end_lnum;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  line = ml_get(lnum);
 | 
					  line = get_line_and_copy(lnum, file_line);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (;;) {
 | 
					  for (;;) {
 | 
				
			||||||
    if (incl_regmatch.regprog != NULL
 | 
					    if (incl_regmatch.regprog != NULL
 | 
				
			||||||
@@ -5687,7 +5697,7 @@ search_line:
 | 
				
			|||||||
            if (lnum >= end_lnum) {
 | 
					            if (lnum >= end_lnum) {
 | 
				
			||||||
              goto exit_matched;
 | 
					              goto exit_matched;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            line = ml_get(++lnum);
 | 
					            line = get_line_and_copy(++lnum, file_line);
 | 
				
			||||||
          } else if (vim_fgets(line = file_line,
 | 
					          } else if (vim_fgets(line = file_line,
 | 
				
			||||||
                               LSIZE, files[depth].fp)) {
 | 
					                               LSIZE, files[depth].fp)) {
 | 
				
			||||||
            goto exit_matched;
 | 
					            goto exit_matched;
 | 
				
			||||||
@@ -5879,7 +5889,7 @@ exit_matched:
 | 
				
			|||||||
      if (++lnum > end_lnum) {
 | 
					      if (++lnum > end_lnum) {
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      line = ml_get(lnum);
 | 
					      line = get_line_and_copy(lnum, file_line);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    already = NULL;
 | 
					    already = NULL;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -520,10 +520,30 @@ func Test_quit_with_arglist()
 | 
				
			|||||||
    throw 'Skipped: cannot run vim in terminal'
 | 
					    throw 'Skipped: cannot run vim in terminal'
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
  let buf = RunVimInTerminal('', {'rows': 6})
 | 
					  let buf = RunVimInTerminal('', {'rows': 6})
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, ":set nomore\n")
 | 
				
			||||||
  call term_sendkeys(buf, ":args a b c\n")
 | 
					  call term_sendkeys(buf, ":args a b c\n")
 | 
				
			||||||
  call term_sendkeys(buf, ":quit\n")
 | 
					  call term_sendkeys(buf, ":quit\n")
 | 
				
			||||||
 | 
					  call term_wait(buf)
 | 
				
			||||||
  call WaitForAssert({-> assert_match('^E173:', term_getline(buf, 6))})
 | 
					  call WaitForAssert({-> assert_match('^E173:', term_getline(buf, 6))})
 | 
				
			||||||
  call StopVimInTerminal(buf)
 | 
					  call StopVimInTerminal(buf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Try :confirm quit with unedited files in arglist
 | 
				
			||||||
 | 
					  let buf = RunVimInTerminal('', {'rows': 6})
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, ":set nomore\n")
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, ":args a b c\n")
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, ":confirm quit\n")
 | 
				
			||||||
 | 
					  call term_wait(buf)
 | 
				
			||||||
 | 
					  call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$',
 | 
				
			||||||
 | 
					        \ term_getline(buf, 6))})
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, "N")
 | 
				
			||||||
 | 
					  call term_wait(buf)
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, ":confirm quit\n")
 | 
				
			||||||
 | 
					  call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$',
 | 
				
			||||||
 | 
					        \ term_getline(buf, 6))})
 | 
				
			||||||
 | 
					  call term_sendkeys(buf, "Y")
 | 
				
			||||||
 | 
					  call term_wait(buf)
 | 
				
			||||||
 | 
					  call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
 | 
				
			||||||
 | 
					  only!
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" vim: shiftwidth=2 sts=2 expandtab
 | 
					" vim: shiftwidth=2 sts=2 expandtab
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2226,7 +2226,7 @@ func Test_autocmd_bufreadpre()
 | 
				
			|||||||
  " (even though the position will be invalid, this should make Vim reset the
 | 
					  " (even though the position will be invalid, this should make Vim reset the
 | 
				
			||||||
  " cursor position in the other window.
 | 
					  " cursor position in the other window.
 | 
				
			||||||
  wincmd p
 | 
					  wincmd p
 | 
				
			||||||
  1
 | 
					  1 " set cpo+=g
 | 
				
			||||||
  " won't do anything, but try to set the cursor on an invalid lnum
 | 
					  " won't do anything, but try to set the cursor on an invalid lnum
 | 
				
			||||||
  autocmd BufReadPre <buffer> :norm! 70gg
 | 
					  autocmd BufReadPre <buffer> :norm! 70gg
 | 
				
			||||||
  " triggers BufReadPre, should not move the cursor in either window
 | 
					  " triggers BufReadPre, should not move the cursor in either window
 | 
				
			||||||
@@ -2241,8 +2241,11 @@ func Test_autocmd_bufreadpre()
 | 
				
			|||||||
  close
 | 
					  close
 | 
				
			||||||
  close
 | 
					  close
 | 
				
			||||||
  call delete('XAutocmdBufReadPre.txt')
 | 
					  call delete('XAutocmdBufReadPre.txt')
 | 
				
			||||||
 | 
					  " set cpo-=g
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" FileChangedShell tested in test_filechanged.vim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Tests for the following autocommands:
 | 
					" Tests for the following autocommands:
 | 
				
			||||||
" - FileWritePre	writing a compressed file
 | 
					" - FileWritePre	writing a compressed file
 | 
				
			||||||
" - FileReadPost	reading a compressed file
 | 
					" - FileReadPost	reading a compressed file
 | 
				
			||||||
@@ -2560,7 +2563,29 @@ func Test_BufWrite_lockmarks()
 | 
				
			|||||||
  call delete('Xtest2')
 | 
					  call delete('Xtest2')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" FileChangedShell tested in test_filechanged.vim
 | 
					" Test closing a window or editing another buffer from a FileChangedRO handler
 | 
				
			||||||
 | 
					" in a readonly buffer
 | 
				
			||||||
 | 
					func Test_FileChangedRO_winclose()
 | 
				
			||||||
 | 
					  augroup FileChangedROTest
 | 
				
			||||||
 | 
					    au!
 | 
				
			||||||
 | 
					    autocmd FileChangedRO * quit
 | 
				
			||||||
 | 
					  augroup END
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  set readonly
 | 
				
			||||||
 | 
					  call assert_fails('normal i', 'E788:')
 | 
				
			||||||
 | 
					  close
 | 
				
			||||||
 | 
					  augroup! FileChangedROTest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  augroup FileChangedROTest
 | 
				
			||||||
 | 
					    au!
 | 
				
			||||||
 | 
					    autocmd FileChangedRO * edit Xfile
 | 
				
			||||||
 | 
					  augroup END
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  set readonly
 | 
				
			||||||
 | 
					  call assert_fails('normal i', 'E788:')
 | 
				
			||||||
 | 
					  close
 | 
				
			||||||
 | 
					  augroup! FileChangedROTest
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func LogACmd()
 | 
					func LogACmd()
 | 
				
			||||||
  call add(g:logged, line('$'))
 | 
					  call add(g:logged, line('$'))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1385,6 +1385,35 @@ func Test_cmdwin_tabpage()
 | 
				
			|||||||
  tabclose!
 | 
					  tabclose!
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for the :! command
 | 
				
			||||||
 | 
					func Test_cmd_bang()
 | 
				
			||||||
 | 
					  if !has('unix')
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  let lines =<< trim [SCRIPT]
 | 
				
			||||||
 | 
					    " Test for no previous command
 | 
				
			||||||
 | 
					    call assert_fails('!!', 'E34:')
 | 
				
			||||||
 | 
					    set nomore
 | 
				
			||||||
 | 
					    " Test for cmdline expansion with :!
 | 
				
			||||||
 | 
					    call setline(1, 'foo!')
 | 
				
			||||||
 | 
					    silent !echo <cWORD> > Xfile.out
 | 
				
			||||||
 | 
					    call assert_equal(['foo!'], readfile('Xfile.out'))
 | 
				
			||||||
 | 
					    " Test for using previous command
 | 
				
			||||||
 | 
					    silent !echo \! !
 | 
				
			||||||
 | 
					    call assert_equal(['! echo foo!'], readfile('Xfile.out'))
 | 
				
			||||||
 | 
					    call writefile(v:errors, 'Xresult')
 | 
				
			||||||
 | 
					    call delete('Xfile.out')
 | 
				
			||||||
 | 
					    qall!
 | 
				
			||||||
 | 
					  [SCRIPT]
 | 
				
			||||||
 | 
					  call writefile(lines, 'Xscript')
 | 
				
			||||||
 | 
					  if RunVim([], [], '--clean -S Xscript')
 | 
				
			||||||
 | 
					    call assert_equal([], readfile('Xresult'))
 | 
				
			||||||
 | 
					  endif
 | 
				
			||||||
 | 
					  call delete('Xscript')
 | 
				
			||||||
 | 
					  call delete('Xresult')
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test error: "E135: *Filter* Autocommands must not change current buffer"
 | 
					" Test error: "E135: *Filter* Autocommands must not change current buffer"
 | 
				
			||||||
func Test_cmd_bang_E135()
 | 
					func Test_cmd_bang_E135()
 | 
				
			||||||
  new
 | 
					  new
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -507,6 +507,42 @@ func Test_run_excmd_with_text_locked()
 | 
				
			|||||||
  call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E565:')
 | 
					  call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E565:')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for the :verbose command
 | 
				
			||||||
 | 
					func Test_verbose_cmd()
 | 
				
			||||||
 | 
					  call assert_equal(['  verbose=1'], split(execute('verbose set vbs'), "\n"))
 | 
				
			||||||
 | 
					  call assert_equal(['  verbose=0'], split(execute('0verbose set vbs'), "\n"))
 | 
				
			||||||
 | 
					  let l = execute("4verbose set verbose | set verbose")
 | 
				
			||||||
 | 
					  call assert_equal(['  verbose=4', '  verbose=0'], split(l, "\n"))
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for the :delete command and the related abbreviated commands
 | 
				
			||||||
 | 
					func Test_excmd_delete()
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['^Ibar$'], split(execute('dl'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['^Ibar$'], split(execute('dell'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['^Ibar$'], split(execute('delel'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['^Ibar$'], split(execute('deletl'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['^Ibar$'], split(execute('deletel'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['        bar'], split(execute('dp'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['        bar'], split(execute('dep'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['        bar'], split(execute('delp'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['        bar'], split(execute('delep'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['        bar'], split(execute('deletp'), "\n"))
 | 
				
			||||||
 | 
					  call setline(1, ['foo', "\tbar"])
 | 
				
			||||||
 | 
					  call assert_equal(['        bar'], split(execute('deletep'), "\n"))
 | 
				
			||||||
 | 
					  close!
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Test_not_break_expression_register()
 | 
					func Test_not_break_expression_register()
 | 
				
			||||||
  call setreg('=', '1+1')
 | 
					  call setreg('=', '1+1')
 | 
				
			||||||
  if 0
 | 
					  if 0
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,11 @@ func Test_expandcmd()
 | 
				
			|||||||
  call assert_fails('call expandcmd("make <afile>")', 'E495:')
 | 
					  call assert_fails('call expandcmd("make <afile>")', 'E495:')
 | 
				
			||||||
  enew
 | 
					  enew
 | 
				
			||||||
  call assert_fails('call expandcmd("make %")', 'E499:')
 | 
					  call assert_fails('call expandcmd("make %")', 'E499:')
 | 
				
			||||||
  close
 | 
					  let $FOO="blue\tsky"
 | 
				
			||||||
 | 
					  call setline(1, "$FOO")
 | 
				
			||||||
 | 
					  call assert_equal("grep pat blue\tsky", expandcmd('grep pat <cfile>'))
 | 
				
			||||||
 | 
					  unlet $FOO
 | 
				
			||||||
 | 
					  close!
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test for expanding <sfile>, <slnum> and <sflnum> outside of sourcing a script
 | 
					" Test for expanding <sfile>, <slnum> and <sflnum> outside of sourcing a script
 | 
				
			||||||
@@ -108,5 +112,17 @@ func Test_source_sfile()
 | 
				
			|||||||
  call delete('Xresult')
 | 
					  call delete('Xresult')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for expanding filenames multiple times in a command line
 | 
				
			||||||
 | 
					func Test_expand_filename_multicmd()
 | 
				
			||||||
 | 
					  edit foo
 | 
				
			||||||
 | 
					  call setline(1, 'foo!')
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  call setline(1, 'foo!')
 | 
				
			||||||
 | 
					  new <cword> | new <cWORD>
 | 
				
			||||||
 | 
					  call assert_equal(4, winnr('$'))
 | 
				
			||||||
 | 
					  call assert_equal('foo!', bufname(winbufnr(1)))
 | 
				
			||||||
 | 
					  call assert_equal('foo', bufname(winbufnr(2)))
 | 
				
			||||||
 | 
					  %bwipe!
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" vim: shiftwidth=2 sts=2 expandtab
 | 
					" vim: shiftwidth=2 sts=2 expandtab
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -772,8 +772,12 @@ func Test_filetype_indent_off()
 | 
				
			|||||||
  new Xtest.vim
 | 
					  new Xtest.vim
 | 
				
			||||||
  filetype indent on
 | 
					  filetype indent on
 | 
				
			||||||
  call assert_equal(1, g:did_indent_on)
 | 
					  call assert_equal(1, g:did_indent_on)
 | 
				
			||||||
 | 
					  call assert_equal(['filetype detection:ON  plugin:OFF  indent:ON'],
 | 
				
			||||||
 | 
					        \ execute('filetype')->split("\n"))
 | 
				
			||||||
  filetype indent off
 | 
					  filetype indent off
 | 
				
			||||||
  call assert_equal(0, exists('g:did_indent_on'))
 | 
					  call assert_equal(0, exists('g:did_indent_on'))
 | 
				
			||||||
 | 
					  call assert_equal(['filetype detection:ON  plugin:OFF  indent:OFF'],
 | 
				
			||||||
 | 
					        \ execute('filetype')->split("\n"))
 | 
				
			||||||
  close
 | 
					  close
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,6 +45,14 @@ func Test_filter_fails()
 | 
				
			|||||||
  call assert_fails('filter /pat', 'E476:')
 | 
					  call assert_fails('filter /pat', 'E476:')
 | 
				
			||||||
  call assert_fails('filter /pat/', 'E476:')
 | 
					  call assert_fails('filter /pat/', 'E476:')
 | 
				
			||||||
  call assert_fails('filter /pat/ asdf', 'E492:')
 | 
					  call assert_fails('filter /pat/ asdf', 'E492:')
 | 
				
			||||||
 | 
					  " Using assert_fails() causes E476 instead of E866. So use a try-catch.
 | 
				
			||||||
 | 
					  let caught_e866 = 0
 | 
				
			||||||
 | 
					  try
 | 
				
			||||||
 | 
					    filter /\@>b/ ls
 | 
				
			||||||
 | 
					  catch /E866:/
 | 
				
			||||||
 | 
					    let caught_e866 = 1
 | 
				
			||||||
 | 
					  endtry
 | 
				
			||||||
 | 
					  call assert_equal(1, caught_e866)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  call assert_fails('filter!', 'E471:')
 | 
					  call assert_fails('filter!', 'E471:')
 | 
				
			||||||
  call assert_fails('filter! pat', 'E476:')
 | 
					  call assert_fails('filter! pat', 'E476:')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,6 +66,18 @@ func Test_global_print()
 | 
				
			|||||||
  close!
 | 
					  close!
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for global command with newline character
 | 
				
			||||||
 | 
					func Test_global_newline()
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  call setline(1, ['foo'])
 | 
				
			||||||
 | 
					  exe "g/foo/s/f/h/\<NL>s/o$/w/"
 | 
				
			||||||
 | 
					  call assert_equal('how', getline(1))
 | 
				
			||||||
 | 
					  call setline(1, ["foo\<NL>bar"])
 | 
				
			||||||
 | 
					  exe "g/foo/s/foo\\\<NL>bar/xyz/"
 | 
				
			||||||
 | 
					  call assert_equal('xyz', getline(1))
 | 
				
			||||||
 | 
					  close!
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Test_wrong_delimiter()
 | 
					func Test_wrong_delimiter()
 | 
				
			||||||
  call assert_fails('g x^bxd', 'E146:')
 | 
					  call assert_fails('g x^bxd', 'E146:')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ func Test_edit_bad()
 | 
				
			|||||||
  e! ++enc=utf8 Xfile
 | 
					  e! ++enc=utf8 Xfile
 | 
				
			||||||
  call assert_equal('[?][?][???][??]', getline(1))
 | 
					  call assert_equal('[?][?][???][??]', getline(1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  e! ++enc=utf8 ++bad=_ Xfile
 | 
					  e! ++encoding=utf8 ++bad=_ Xfile
 | 
				
			||||||
  call assert_equal('[_][_][___][__]', getline(1))
 | 
					  call assert_equal('[_][_][___][__]', getline(1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  e! ++enc=utf8 ++bad=drop Xfile
 | 
					  e! ++enc=utf8 ++bad=drop Xfile
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -499,6 +499,7 @@ func Xtest_browse(cchar)
 | 
				
			|||||||
		\ 'RegularLine2']
 | 
							\ 'RegularLine2']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Xfirst
 | 
					  Xfirst
 | 
				
			||||||
 | 
					  call assert_fails('-5Xcc', 'E16:')
 | 
				
			||||||
  call assert_fails('Xprev', 'E553')
 | 
					  call assert_fails('Xprev', 'E553')
 | 
				
			||||||
  call assert_fails('Xpfile', 'E553')
 | 
					  call assert_fails('Xpfile', 'E553')
 | 
				
			||||||
  Xnfile
 | 
					  Xnfile
 | 
				
			||||||
@@ -4415,6 +4416,20 @@ func Test_splitview()
 | 
				
			|||||||
  call assert_equal(0, getloclist(0, {'winid' : 0}).winid)
 | 
					  call assert_equal(0, getloclist(0, {'winid' : 0}).winid)
 | 
				
			||||||
  new | only
 | 
					  new | only
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Using :split or :vsplit from a quickfix window should behave like a :new
 | 
				
			||||||
 | 
					  " or a :vnew command
 | 
				
			||||||
 | 
					  copen
 | 
				
			||||||
 | 
					  split
 | 
				
			||||||
 | 
					  call assert_equal(3, winnr('$'))
 | 
				
			||||||
 | 
					  let l = getwininfo()
 | 
				
			||||||
 | 
					  call assert_equal([0, 0, 1], [l[0].quickfix, l[1].quickfix, l[2].quickfix])
 | 
				
			||||||
 | 
					  close
 | 
				
			||||||
 | 
					  copen
 | 
				
			||||||
 | 
					  vsplit
 | 
				
			||||||
 | 
					  let l = getwininfo()
 | 
				
			||||||
 | 
					  call assert_equal([0, 0, 1], [l[0].quickfix, l[1].quickfix, l[2].quickfix])
 | 
				
			||||||
 | 
					  new | only
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  call delete('Xtestfile1')
 | 
					  call delete('Xtestfile1')
 | 
				
			||||||
  call delete('Xtestfile2')
 | 
					  call delete('Xtestfile2')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1600,6 +1600,33 @@ func Test_search_tilde_pat()
 | 
				
			|||||||
  call delete('Xresult')
 | 
					  call delete('Xresult')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for searching a pattern that is not present with 'nowrapscan'
 | 
				
			||||||
 | 
					func Test_search_pat_not_found()
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  set nowrapscan
 | 
				
			||||||
 | 
					  let @/ = '1abcxyz2'
 | 
				
			||||||
 | 
					  call assert_fails('normal n', 'E385:')
 | 
				
			||||||
 | 
					  call assert_fails('normal N', 'E384:')
 | 
				
			||||||
 | 
					  set wrapscan&
 | 
				
			||||||
 | 
					  close
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for v:searchforward variable
 | 
				
			||||||
 | 
					func Test_searchforward_var()
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  call setline(1, ['foo', '', 'foo'])
 | 
				
			||||||
 | 
					  call cursor(2, 1)
 | 
				
			||||||
 | 
					  let @/ = 'foo'
 | 
				
			||||||
 | 
					  let v:searchforward = 0
 | 
				
			||||||
 | 
					  normal N
 | 
				
			||||||
 | 
					  call assert_equal(3, line('.'))
 | 
				
			||||||
 | 
					  call cursor(2, 1)
 | 
				
			||||||
 | 
					  let v:searchforward = 1
 | 
				
			||||||
 | 
					  normal N
 | 
				
			||||||
 | 
					  call assert_equal(1, line('.'))
 | 
				
			||||||
 | 
					  close!
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test 'smartcase' with utf-8.
 | 
					" Test 'smartcase' with utf-8.
 | 
				
			||||||
func Test_search_smartcase_utf8()
 | 
					func Test_search_smartcase_utf8()
 | 
				
			||||||
  new
 | 
					  new
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -278,7 +278,6 @@ func Test_swap_recover_ext()
 | 
				
			|||||||
    autocmd SwapExists * let v:swapchoice = 'r'
 | 
					    autocmd SwapExists * let v:swapchoice = 'r'
 | 
				
			||||||
  augroup END
 | 
					  augroup END
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  " Create a valid swapfile by editing a file with a special extension.
 | 
					  " Create a valid swapfile by editing a file with a special extension.
 | 
				
			||||||
  split Xtest.scr
 | 
					  split Xtest.scr
 | 
				
			||||||
  call setline(1, ['one', 'two', 'three'])
 | 
					  call setline(1, ['one', 'two', 'three'])
 | 
				
			||||||
@@ -311,6 +310,46 @@ func Test_swap_recover_ext()
 | 
				
			|||||||
  augroup! test_swap_recover_ext
 | 
					  augroup! test_swap_recover_ext
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for closing a split window automatically when a swap file is detected
 | 
				
			||||||
 | 
					" and 'Q' is selected in the confirmation prompt.
 | 
				
			||||||
 | 
					func Test_swap_split_win()
 | 
				
			||||||
 | 
					  autocmd! SwapExists
 | 
				
			||||||
 | 
					  augroup test_swap_splitwin
 | 
				
			||||||
 | 
					    autocmd!
 | 
				
			||||||
 | 
					    autocmd SwapExists * let v:swapchoice = 'q'
 | 
				
			||||||
 | 
					  augroup END
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Create a valid swapfile by editing a file with a special extension.
 | 
				
			||||||
 | 
					  split Xtest.scr
 | 
				
			||||||
 | 
					  call setline(1, ['one', 'two', 'three'])
 | 
				
			||||||
 | 
					  write  " file is written, not modified
 | 
				
			||||||
 | 
					  write  " write again to make sure the swapfile is created
 | 
				
			||||||
 | 
					  " read the swapfile as a Blob
 | 
				
			||||||
 | 
					  let swapfile_name = swapname('%')
 | 
				
			||||||
 | 
					  let swapfile_bytes = readfile(swapfile_name, 'B')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Close and delete the file and recreate the swap file.
 | 
				
			||||||
 | 
					  quit
 | 
				
			||||||
 | 
					  call delete('Xtest.scr')
 | 
				
			||||||
 | 
					  call writefile(swapfile_bytes, swapfile_name)
 | 
				
			||||||
 | 
					  " Split edit the file again. This should fail to open the window
 | 
				
			||||||
 | 
					  try
 | 
				
			||||||
 | 
					    split Xtest.scr
 | 
				
			||||||
 | 
					  catch
 | 
				
			||||||
 | 
					    " E308 should be caught, not E306.
 | 
				
			||||||
 | 
					    call assert_exception('E308:')  " Original file may have been changed
 | 
				
			||||||
 | 
					  endtry
 | 
				
			||||||
 | 
					  call assert_equal(1, winnr('$'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  call delete('Xtest.scr')
 | 
				
			||||||
 | 
					  call delete(swapfile_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  augroup test_swap_splitwin
 | 
				
			||||||
 | 
					      autocmd!
 | 
				
			||||||
 | 
					  augroup END
 | 
				
			||||||
 | 
					  augroup! test_swap_splitwin
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test for selecting 'q' in the attention prompt
 | 
					" Test for selecting 'q' in the attention prompt
 | 
				
			||||||
func Test_swap_prompt_splitwin()
 | 
					func Test_swap_prompt_splitwin()
 | 
				
			||||||
  CheckRunVimInTerminal
 | 
					  CheckRunVimInTerminal
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1180,9 +1180,20 @@ func Test_inc_search()
 | 
				
			|||||||
  close!
 | 
					  close!
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" this was using a line from ml_get() freed by the regexp
 | 
				
			||||||
 | 
					func Test_isearch_copy_line()
 | 
				
			||||||
 | 
					  new
 | 
				
			||||||
 | 
					  norm o
 | 
				
			||||||
 | 
					  norm 0
 | 
				
			||||||
 | 
					  0norm o
 | 
				
			||||||
 | 
					  sil! norm bc0
 | 
				
			||||||
 | 
					  sil! isearch \%')
 | 
				
			||||||
 | 
					  bwipe!
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test for :dsearch, :dlist, :djump and :dsplit commands
 | 
					" Test for :dsearch, :dlist, :djump and :dsplit commands
 | 
				
			||||||
" Test for [d, ]d, [D, ]D, [ CTRL-D, ] CTRL-D and CTRL-W d commands
 | 
					" Test for [d, ]d, [D, ]D, [ CTRL-D, ] CTRL-D and CTRL-W d commands
 | 
				
			||||||
func Test_def_search()
 | 
					func Test_macro_search()
 | 
				
			||||||
  new
 | 
					  new
 | 
				
			||||||
  call setline(1, ['#define FOO 1', '#define FOO 2', '#define FOO 3',
 | 
					  call setline(1, ['#define FOO 1', '#define FOO 2', '#define FOO 3',
 | 
				
			||||||
        \ '#define FOO 4', '#define FOO 5'])
 | 
					        \ '#define FOO 4', '#define FOO 5'])
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1996,6 +1996,47 @@ func Test_reload_in_try_catch()
 | 
				
			|||||||
  call delete('Xreload')
 | 
					  call delete('Xreload')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for errors with :catch, :throw, :finally                            {{{1
 | 
				
			||||||
 | 
					func Test_try_catch_errors()
 | 
				
			||||||
 | 
					  call assert_fails('throw |', 'E471:')
 | 
				
			||||||
 | 
					  call assert_fails("throw \n ", 'E471:')
 | 
				
			||||||
 | 
					  call assert_fails('catch abc', 'E603:')
 | 
				
			||||||
 | 
					  call assert_fails('try | let i = 1| finally | catch | endtry', 'E604:')
 | 
				
			||||||
 | 
					  call assert_fails('finally', 'E606:')
 | 
				
			||||||
 | 
					  call assert_fails('try | finally | finally | endtry', 'E607:')
 | 
				
			||||||
 | 
					  " v8.2.3486 has been ported, but v8.2.1183 hasn't, so E170 appears here.
 | 
				
			||||||
 | 
					  " call assert_fails('try | for i in range(5) | endif | endtry', 'E580:')
 | 
				
			||||||
 | 
					  call assert_fails('try | for i in range(5) | endif | endtry', 'E170:')
 | 
				
			||||||
 | 
					  call assert_fails('try | while v:true | endtry', 'E170:')
 | 
				
			||||||
 | 
					  call assert_fails('try | if v:true | endtry', 'E171:')
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for verbose messages with :try :catch, and :finally                 {{{1
 | 
				
			||||||
 | 
					func Test_try_catch_verbose()
 | 
				
			||||||
 | 
					  " This test works only when the language is English
 | 
				
			||||||
 | 
					  if v:lang != "C" && v:lang !~ '^[Ee]n'
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  set verbose=14
 | 
				
			||||||
 | 
					  redir => msg
 | 
				
			||||||
 | 
					  try
 | 
				
			||||||
 | 
					    echo i
 | 
				
			||||||
 | 
					  catch /E121:/
 | 
				
			||||||
 | 
					  finally
 | 
				
			||||||
 | 
					  endtry
 | 
				
			||||||
 | 
					  redir END
 | 
				
			||||||
 | 
					  let expected = [
 | 
				
			||||||
 | 
					        \ 'Exception thrown: Vim(echo):E121: Undefined variable: i',
 | 
				
			||||||
 | 
					        \ '',
 | 
				
			||||||
 | 
					        \ 'Exception caught: Vim(echo):E121: Undefined variable: i',
 | 
				
			||||||
 | 
					        \ '',
 | 
				
			||||||
 | 
					        \ 'Exception finished: Vim(echo):E121: Undefined variable: i'
 | 
				
			||||||
 | 
					        \ ]
 | 
				
			||||||
 | 
					  call assert_equal(expected, split(msg, "\n"))
 | 
				
			||||||
 | 
					  set verbose&
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test for using throw in a called function with following error    {{{1
 | 
					" Test for using throw in a called function with following error    {{{1
 | 
				
			||||||
func Test_user_command_throw_in_function_call()
 | 
					func Test_user_command_throw_in_function_call()
 | 
				
			||||||
  let lines =<< trim END
 | 
					  let lines =<< trim END
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1782,6 +1782,29 @@ func Test_missing_end()
 | 
				
			|||||||
  call writefile(['try', 'echo "."'], 'Xscript')
 | 
					  call writefile(['try', 'echo "."'], 'Xscript')
 | 
				
			||||||
  call assert_fails('source Xscript', 'E600:')
 | 
					  call assert_fails('source Xscript', 'E600:')
 | 
				
			||||||
  call delete('Xscript')
 | 
					  call delete('Xscript')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Using endfor with :while
 | 
				
			||||||
 | 
					  let caught_e732 = 0
 | 
				
			||||||
 | 
					  try
 | 
				
			||||||
 | 
					    while v:true
 | 
				
			||||||
 | 
					    endfor
 | 
				
			||||||
 | 
					  catch /E732:/
 | 
				
			||||||
 | 
					    let caught_e732 = 1
 | 
				
			||||||
 | 
					  endtry
 | 
				
			||||||
 | 
					  call assert_equal(1, caught_e732)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Using endwhile with :for
 | 
				
			||||||
 | 
					  let caught_e733 = 0
 | 
				
			||||||
 | 
					  try
 | 
				
			||||||
 | 
					    for i in range(1)
 | 
				
			||||||
 | 
					    endwhile
 | 
				
			||||||
 | 
					  catch /E733:/
 | 
				
			||||||
 | 
					    let caught_e733 = 1
 | 
				
			||||||
 | 
					  endtry
 | 
				
			||||||
 | 
					  call assert_equal(1, caught_e733)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Missing 'in' in a :for statement
 | 
				
			||||||
 | 
					  call assert_fails('for i range(1) | endfor', 'E690:')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Test for deep nesting of if/for/while/try statements              {{{1
 | 
					" Test for deep nesting of if/for/while/try statements              {{{1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -919,6 +919,14 @@ func Test_winpos_errors()
 | 
				
			|||||||
  call assert_fails('winpos 10', 'E466:')
 | 
					  call assert_fails('winpos 10', 'E466:')
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Test for +cmd in a :split command
 | 
				
			||||||
 | 
					func Test_split_cmd()
 | 
				
			||||||
 | 
					  split +set\ readonly
 | 
				
			||||||
 | 
					  call assert_equal(1, &readonly)
 | 
				
			||||||
 | 
					  call assert_equal(2, winnr('$'))
 | 
				
			||||||
 | 
					  close
 | 
				
			||||||
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Test_window_resize()
 | 
					func Test_window_resize()
 | 
				
			||||||
  throw 'Skipped: Nvim supports cmdheight=0'
 | 
					  throw 'Skipped: Nvim supports cmdheight=0'
 | 
				
			||||||
  " Vertical :resize (absolute, relative, min and max size).
 | 
					  " Vertical :resize (absolute, relative, min and max size).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,10 @@
 | 
				
			|||||||
-- Test argument list commands
 | 
					-- Test argument list commands
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local helpers = require('test.functional.helpers')(after_each)
 | 
					local helpers = require('test.functional.helpers')(after_each)
 | 
				
			||||||
 | 
					local Screen = require('test.functional.ui.screen')
 | 
				
			||||||
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
 | 
					local clear, command, eq = helpers.clear, helpers.command, helpers.eq
 | 
				
			||||||
local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq
 | 
					local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq
 | 
				
			||||||
 | 
					local feed = helpers.feed
 | 
				
			||||||
local pcall_err = helpers.pcall_err
 | 
					local pcall_err = helpers.pcall_err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('argument list commands', function()
 | 
					describe('argument list commands', function()
 | 
				
			||||||
@@ -236,7 +238,43 @@ describe('argument list commands', function()
 | 
				
			|||||||
  end)
 | 
					  end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('quitting Vim with unedited files in the argument list throws E173', function()
 | 
					  it('quitting Vim with unedited files in the argument list throws E173', function()
 | 
				
			||||||
 | 
					    command('set nomore')
 | 
				
			||||||
    command('args a b c')
 | 
					    command('args a b c')
 | 
				
			||||||
    eq('Vim(quit):E173: 2 more files to edit', pcall_err(command, 'quit'))
 | 
					    eq('Vim(quit):E173: 2 more files to edit', pcall_err(command, 'quit'))
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it(':confirm quit with unedited files in arglist', function()
 | 
				
			||||||
 | 
					    local screen = Screen.new(60, 6)
 | 
				
			||||||
 | 
					    screen:attach()
 | 
				
			||||||
 | 
					    command('set nomore')
 | 
				
			||||||
 | 
					    command('args a b c')
 | 
				
			||||||
 | 
					    feed(':confirm quit\n')
 | 
				
			||||||
 | 
					    screen:expect([[
 | 
				
			||||||
 | 
					                                                                  |
 | 
				
			||||||
 | 
					      ~                                                           |
 | 
				
			||||||
 | 
					                                                                  |
 | 
				
			||||||
 | 
					      :confirm quit                                               |
 | 
				
			||||||
 | 
					      2 more files to edit.  Quit anyway?                         |
 | 
				
			||||||
 | 
					      [Y]es, (N)o: ^                                               |
 | 
				
			||||||
 | 
					    ]])
 | 
				
			||||||
 | 
					    feed('N')
 | 
				
			||||||
 | 
					    screen:expect([[
 | 
				
			||||||
 | 
					      ^                                                            |
 | 
				
			||||||
 | 
					      ~                                                           |
 | 
				
			||||||
 | 
					      ~                                                           |
 | 
				
			||||||
 | 
					      ~                                                           |
 | 
				
			||||||
 | 
					      ~                                                           |
 | 
				
			||||||
 | 
					                                                                  |
 | 
				
			||||||
 | 
					    ]])
 | 
				
			||||||
 | 
					    feed(':confirm quit\n')
 | 
				
			||||||
 | 
					    screen:expect([[
 | 
				
			||||||
 | 
					                                                                  |
 | 
				
			||||||
 | 
					      ~                                                           |
 | 
				
			||||||
 | 
					                                                                  |
 | 
				
			||||||
 | 
					      :confirm quit                                               |
 | 
				
			||||||
 | 
					      2 more files to edit.  Quit anyway?                         |
 | 
				
			||||||
 | 
					      [Y]es, (N)o: ^                                               |
 | 
				
			||||||
 | 
					    ]])
 | 
				
			||||||
 | 
					    feed('Y')
 | 
				
			||||||
 | 
					  end)
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user