aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/old/testdir
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/old/testdir')
-rw-r--r--test/old/testdir/gen_opt_test.vim39
-rw-r--r--test/old/testdir/runnvim.vim3
-rw-r--r--test/old/testdir/runtest.vim4
-rw-r--r--test/old/testdir/setup.vim3
-rw-r--r--test/old/testdir/test_autocmd.vim28
-rw-r--r--test/old/testdir/test_bufwintabinfo.vim12
-rw-r--r--test/old/testdir/test_cmdline.vim33
-rw-r--r--test/old/testdir/test_compiler.vim637
-rw-r--r--test/old/testdir/test_debugger.vim5
-rw-r--r--test/old/testdir/test_diffmode.vim479
-rw-r--r--test/old/testdir/test_digraph.vim10
-rw-r--r--test/old/testdir/test_filetype.vim151
-rw-r--r--test/old/testdir/test_functions.vim138
-rw-r--r--test/old/testdir/test_highlight.vim4
-rw-r--r--test/old/testdir/test_indent.vim76
-rw-r--r--test/old/testdir/test_ins_complete.vim308
-rw-r--r--test/old/testdir/test_let.vim18
-rw-r--r--test/old/testdir/test_matchfuzzy.vim62
-rw-r--r--test/old/testdir/test_messages.vim47
-rw-r--r--test/old/testdir/test_normal.vim21
-rw-r--r--test/old/testdir/test_options.vim59
-rw-r--r--test/old/testdir/test_perl.vim5
-rw-r--r--test/old/testdir/test_popup.vim230
-rw-r--r--test/old/testdir/test_preview.vim59
-rw-r--r--test/old/testdir/test_python3.vim5
-rw-r--r--test/old/testdir/test_pyx3.vim5
-rw-r--r--test/old/testdir/test_ruby.vim11
-rw-r--r--test/old/testdir/test_shift.vim807
-rw-r--r--test/old/testdir/test_spell.vim12
-rw-r--r--test/old/testdir/test_stacktrace.vim142
-rw-r--r--test/old/testdir/test_statusline.vim4
-rw-r--r--test/old/testdir/test_tagjump.vim4
-rw-r--r--test/old/testdir/test_termdebug.vim6
-rw-r--r--test/old/testdir/test_user_func.vim74
-rw-r--r--test/old/testdir/test_visual.vim72
-rw-r--r--test/old/testdir/test_window_cmd.vim51
-rw-r--r--test/old/testdir/test_winfixbuf.vim18
37 files changed, 3480 insertions, 162 deletions
diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim
index be5a7e6ee4..f12ce8c7c4 100644
--- a/test/old/testdir/gen_opt_test.vim
+++ b/test/old/testdir/gen_opt_test.vim
@@ -87,7 +87,7 @@ let test_values = {
\ ['xxx', 'help,nofile']],
\ 'clipboard': [['', 'unnamed'], ['xxx', '\ze*', 'exclude:\\%(']],
\ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
- \ 'noinsert', 'noselect', 'fuzzy', 'menu,longest'],
+ \ 'noinsert', 'noselect', 'fuzzy', 'preinsert', 'menu,longest'],
\ ['xxx', 'menu,,,longest,']],
\ 'encoding': [['utf8'], []],
\ 'foldcolumn': [[0, 1, 4, 'auto', 'auto:1', 'auto:9'], [-1, 13, 999]],
@@ -117,12 +117,11 @@ let test_values = {
"\ 'imstyle': [[0, 1], [-1, 2, 999]],
\ 'lines': [[2, 24, 1000], [-1, 0, 1]],
\ 'linespace': [[-1, 0, 2, 4, 999], ['']],
- \ 'msghistory': [[0, 1, 100, 10000], [-1, 10001]],
\ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
\ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
\ 'report': [[0, 1, 2, 9999], [-1]],
- \ 'scroll': [[0, 1, 2, 20], [-1, 999]],
- \ 'scrolljump': [[-100, -1, 0, 1, 2, 20], [-101, 999]],
+ \ 'scroll': [[0, 1, 2, 15], [-1, 999]],
+ \ 'scrolljump': [[-100, -1, 0, 1, 2, 15], [-101, 999]],
\ 'scrolloff': [[0, 1, 8, 999], [-1]],
\ 'shiftwidth': [[0, 1, 8, 999], [-1]],
\ 'sidescroll': [[0, 1, 8, 999], [-1]],
@@ -146,8 +145,8 @@ let test_values = {
\ 'winwidth': [[1, 10, 999], [-1, 0]],
\
"\ string options
- \ 'ambiwidth': [['', 'single', 'double'], ['xxx']],
- \ 'background': [['', 'light', 'dark'], ['xxx']],
+ \ 'ambiwidth': [['single', 'double'], ['xxx']],
+ \ 'background': [['light', 'dark'], ['xxx']],
"\ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop',
"\ " 'eol,start', 'indent,eol,nostop'],
"\ " [-1, 4, 'xxx']],
@@ -187,7 +186,7 @@ let test_values = {
\ ['xxx']],
\ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']],
"\ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
- "\ " 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'menu,longest'],
+ "\ " 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'preinsert', 'menu,longest'],
"\ " ['xxx', 'menu,,,longest,']],
\ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'],
\ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr',
@@ -210,17 +209,19 @@ let test_values = {
\ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical',
\ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12',
\ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers',
- \ 'algorithm:minimal', 'algorithm:patience',
- \ 'algorithm:histogram', 'icase,iwhite'],
- \ ['xxx', 'foldcolumn:xxx', 'algorithm:xxx', 'algorithm:']],
+ \ 'icase,iwhite', 'algorithm:minimal', 'algorithm:patience',
+ \ 'algorithm:histogram', 'linematch:5'],
+ \ ['xxx', 'foldcolumn:', 'foldcolumn:x', 'foldcolumn:xxx',
+ \ 'linematch:', 'linematch:x', 'linematch:xxx', 'algorithm:',
+ \ 'algorithm:xxx', 'context:', 'context:x', 'context:xxx']],
\ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'],
\ ['xxx']],
- \ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
+ \ 'eadirection': [['both', 'ver', 'hor'], ['xxx', 'ver,hor']],
"\ 'encoding': [['latin1'], ['xxx', '']],
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
\ ['xxx']],
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
- \ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
+ \ 'fileformat': [['dos', 'unix', 'mac'], ['xxx']],
\ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
\ 'fillchars': [['', 'stl:x', 'stlnc:x', 'vert:x', 'fold:x', 'foldopen:x',
\ 'foldclose:x', 'foldsep:x', 'diff:x', 'eob:x', 'lastline:x',
@@ -264,10 +265,18 @@ let test_values = {
\ 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
\ ['xxx', 'eol:']],
\ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
+ \ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000',
+ \ 'history:100,wait:100', 'history:0,wait:0',
+ \ 'hit-enter,history:1,wait:1'],
+ \ ['xxx', 'history:500', 'hit-enter,history:-1',
+ \ 'hit-enter,history:10001', 'history:0,wait:10001',
+ \ 'hit-enter', 'history:10,wait:99999999999999999999',
+ \ 'history:99999999999999999999,wait:10', 'wait:10',
+ \ 'history:-10', 'history:10,wait:-10']],
\ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
\ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
\ ['xxx', 'n,v,i']],
- \ 'mousemodel': [['', 'extend', 'popup', 'popup_setpos'], ['xxx']],
+ \ 'mousemodel': [['extend', 'popup', 'popup_setpos'], ['xxx']],
\ 'mouseshape': [['', 'n:arrow'], ['xxx']],
\ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank',
\ 'alpha,hex,bin'],
@@ -292,7 +301,7 @@ let test_values = {
\ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir',
\ 'help,options,slash'],
\ ['xxx', 'curdir,sesdir']],
- \ 'showcmdloc': [['', 'last', 'statusline', 'tabline'], ['xxx']],
+ \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
"\ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']],
\ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
\ '/tmp/dir\ with\ space/en.utf-8.add',
@@ -304,7 +313,7 @@ let test_values = {
\ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100',
\ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'],
\ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']],
- \ 'splitkeep': [['', 'cursor', 'screen', 'topline'], ['xxx']],
+ \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']],
\ 'statusline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
"\ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
\ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab',
diff --git a/test/old/testdir/runnvim.vim b/test/old/testdir/runnvim.vim
index 578614c8a1..f5945aeaee 100644
--- a/test/old/testdir/runnvim.vim
+++ b/test/old/testdir/runnvim.vim
@@ -8,6 +8,7 @@ function s:logger.on_exit(id, data, event)
endfunction
let s:logger.env = #{VIMRUNTIME: $VIMRUNTIME}
+let s:logger.term = v:true
" Replace non-printable chars by special sequence, or "<%x>".
let s:escaped_char = {"\n": '\n', "\r": '\r', "\t": '\t'}
@@ -25,7 +26,7 @@ function Main()
set lines=25
set columns=80
enew
- let job = termopen(args, s:logger)
+ let job = jobstart(args, s:logger)
let results = jobwait([job], 5 * 60 * 1000)
" TODO(ZyX-I): Get colors
let screen = getline(1, '$')
diff --git a/test/old/testdir/runtest.vim b/test/old/testdir/runtest.vim
index 058635c332..3d210695c4 100644
--- a/test/old/testdir/runtest.vim
+++ b/test/old/testdir/runtest.vim
@@ -55,6 +55,10 @@ silent! endwhile
" In the GUI we can always change the screen size.
if has('gui_running')
+ if has('gui_gtk')
+ " to keep screendump size unchanged
+ set guifont=Monospace\ 10
+ endif
set columns=80 lines=25
endif
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index e7b4bb1a88..61596fc83a 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -1,6 +1,5 @@
if exists('s:did_load')
" Align Nvim defaults to Vim.
- set backspace=
set commentstring=/*\ %s\ */
set complete=.,w,b,u,t,i
set define=^\\s*#\\s*define
@@ -66,7 +65,7 @@ mapclear
mapclear!
aunmenu *
tlunmenu *
-autocmd! nvim_popupmenu
+autocmd! nvim.popupmenu
" Undo the 'grepprg' and 'grepformat' setting in _defaults.lua.
set grepprg& grepformat&
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 64599c869a..d5f7c928de 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -1198,8 +1198,8 @@ func Test_OptionSet()
call assert_equal(g:opt[0], g:opt[1])
" 14: Setting option backspace through :let"
- let g:options = [['backspace', '', '', '', 'eol,indent,start', 'global', 'set']]
- let &bs = "eol,indent,start"
+ let g:options = [['backspace', 'indent,eol,start', 'indent,eol,start', 'indent,eol,start', '', 'global', 'set']]
+ let &bs = ''
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
@@ -4181,4 +4181,28 @@ func Test_autocmd_BufWinLeave_with_vsp()
exe "bw! " .. dummy
endfunc
+func Test_OptionSet_cmdheight()
+ set mouse=a laststatus=2
+ au OptionSet cmdheight :let &l:ch = v:option_new
+
+ resize -1
+ call assert_equal(2, &l:ch)
+ resize +1
+ call assert_equal(1, &l:ch)
+
+ call Ntest_setmouse(&lines - 1, 1)
+ call feedkeys("\<LeftMouse>", 'xt')
+ call Ntest_setmouse(&lines - 2, 1)
+ call feedkeys("\<LeftDrag>", 'xt')
+ call assert_equal(2, &l:ch)
+
+ tabnew | resize +1
+ call assert_equal(1, &l:ch)
+ tabfirst
+ call assert_equal(2, &l:ch)
+
+ tabonly
+ set cmdheight& mouse& laststatus&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_bufwintabinfo.vim b/test/old/testdir/test_bufwintabinfo.vim
index 57492e07c9..0a4bd0b674 100644
--- a/test/old/testdir/test_bufwintabinfo.vim
+++ b/test/old/testdir/test_bufwintabinfo.vim
@@ -114,6 +114,18 @@ func Test_getbufwintabinfo()
wincmd t | only
endfunc
+function Test_get_wininfo_leftcol()
+ set nowrap
+ set winwidth=10
+ vsp
+ call setline(1, ['abcdefghijklmnopqrstuvwxyz'])
+ norm! 5zl
+ call assert_equal(5, getwininfo()[0].leftcol)
+ bwipe!
+ set wrap&
+ set winwidth&
+endfunc
+
function Test_get_buf_options()
let opts = bufnr()->getbufvar('&')
call assert_equal(v:t_dict, type(opts))
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
index 290af4a4ca..d4ad63d43e 100644
--- a/test/old/testdir/test_cmdline.vim
+++ b/test/old/testdir/test_cmdline.vim
@@ -291,8 +291,8 @@ func Test_changing_cmdheight()
call term_sendkeys(buf, ":resize -3\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_1', {})
- " using the space available doesn't change the status line
- call term_sendkeys(buf, ":set cmdheight+=3\<CR>")
+ " :resize now also changes 'cmdheight' accordingly
+ call term_sendkeys(buf, ":set cmdheight+=1\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {})
" using more space moves the status line up
@@ -300,10 +300,10 @@ func Test_changing_cmdheight()
call VerifyScreenDump(buf, 'Test_changing_cmdheight_3', {})
" reducing cmdheight moves status line down
- call term_sendkeys(buf, ":set cmdheight-=2\<CR>")
+ call term_sendkeys(buf, ":set cmdheight-=3\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {})
- " reducing window size and then setting cmdheight
+ " reducing window size and then setting cmdheight
call term_sendkeys(buf, ":resize -1\<CR>")
call term_sendkeys(buf, ":set cmdheight=1\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_5', {})
@@ -316,6 +316,10 @@ func Test_changing_cmdheight()
call term_sendkeys(buf, ":call EchoOne()\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_7', {})
+ " window commands do not reduce 'cmdheight' to value lower than :set by user
+ call term_sendkeys(buf, "\<CR>:wincmd _\<CR>")
+ call VerifyScreenDump(buf, 'Test_changing_cmdheight_8', {})
+
" clean up
call StopVimInTerminal(buf)
endfunc
@@ -4036,6 +4040,27 @@ func Test_rulerformat_position()
call StopVimInTerminal(buf)
endfunc
+" Test for using "%!" in 'rulerformat' to use a function
+func Test_rulerformat_function()
+ CheckScreendump
+
+ let lines =<< trim END
+ func TestRulerFn()
+ return '10,20%=30%%'
+ endfunc
+ END
+ call writefile(lines, 'Xrulerformat_function', 'D')
+
+ let buf = RunVimInTerminal('-S Xrulerformat_function', #{rows: 2, cols: 40})
+ call term_sendkeys(buf, ":set ruler rulerformat=%!TestRulerFn()\<CR>")
+ call term_sendkeys(buf, ":redraw!\<CR>")
+ call term_wait(buf)
+ call VerifyScreenDump(buf, 'Test_rulerformat_function', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_getcompletion_usercmd()
command! -nargs=* -complete=command TestCompletion echo <q-args>
diff --git a/test/old/testdir/test_compiler.vim b/test/old/testdir/test_compiler.vim
index 07b57b76d9..1310cbadfc 100644
--- a/test/old/testdir/test_compiler.vim
+++ b/test/old/testdir/test_compiler.vim
@@ -18,6 +18,8 @@ func Test_compiler()
endif
e Xfoo.pl
+ " Play nice with other tests.
+ defer setqflist([])
compiler perl
call assert_equal('perl', b:current_compiler)
call assert_fails('let g:current_compiler', 'E121:')
@@ -65,10 +67,10 @@ func Test_compiler_completion()
call assert_match('^"compiler ' .. clist .. '$', @:)
call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', @:)
+ call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pyunit', @:)
call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', @:)
+ call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pyunit', @:)
endfunc
func Test_compiler_error()
@@ -78,3 +80,634 @@ func Test_compiler_error()
call assert_fails('compiler! doesnotexist', 'E666:')
unlet! g:current_compiler
endfunc
+
+func s:SpotBugsParseFilterMakePrg(dirname, makeprg)
+ let result = {}
+ let result.sourcepath = ''
+ let result.classfiles = []
+
+ " Get the argument after the rightmost occurrence of "-sourcepath".
+ let offset = strridx(a:makeprg, '-sourcepath')
+ if offset < 0
+ return result
+ endif
+ let offset += 1 + strlen('-sourcepath')
+ let result.sourcepath = matchstr(strpart(a:makeprg, offset), '.\{-}\ze[ \t]')
+ let offset += 1 + strlen(result.sourcepath)
+
+ " Get the class file arguments, dropping the pathname prefix.
+ let offset = stridx(a:makeprg, a:dirname, offset)
+ if offset < 0
+ return result
+ endif
+
+ while offset > -1
+ let candidate = matchstr(a:makeprg, '[^ \t]\{-}\.class\>', offset)
+ if empty(candidate)
+ break
+ endif
+ call add(result.classfiles, candidate)
+ let offset = stridx(a:makeprg, a:dirname, (1 + strlen(candidate) + offset))
+ endwhile
+
+ call sort(result.classfiles)
+ return result
+endfunc
+
+func Test_compiler_spotbugs_makeprg()
+ let save_shellslash = &shellslash
+ set shellslash
+
+ call assert_true(mkdir('Xspotbugs/src/tests/α/β/γ/δ', 'pR'))
+ call assert_true(mkdir('Xspotbugs/tests/α/β/γ/δ', 'pR'))
+
+ let lines =<< trim END
+ // EOL comment. /*
+ abstract class
+ 𐌂1 /* Multiline comment. */ {
+ /* Multiline comment. */ // EOL comment. /*
+ static final String COMMENT_A_LIKE = "/*";
+ { new Object() {/* Try globbing. */}; }
+ static { interface 𐌉𐌉1 {} }
+ static class 𐌂11 { interface 𐌉𐌉2 {} }
+ }
+ /* Multiline comment. */ // EOL comment. /*
+ final class 𐌂2 {
+ public static void main(String... aa) {
+ record 𐌓() {}
+ enum 𐌄 {}
+ }
+ } // class
+ END
+
+ " THE EXPECTED RESULTS.
+ let results = {}
+ let results['Xspotbugs/src/tests/𐌂1.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/𐌂1.java',
+ \ ':p:h:S')},
+ \ 'classfiles': sort([
+ \ 'Xspotbugs/tests/𐌂1$1.class',
+ \ 'Xspotbugs/tests/𐌂1$1𐌉𐌉1.class',
+ \ 'Xspotbugs/tests/𐌂1$𐌂11$𐌉𐌉2.class',
+ \ 'Xspotbugs/tests/𐌂1$𐌂11.class',
+ \ 'Xspotbugs/tests/𐌂1.class',
+ \ 'Xspotbugs/tests/𐌂2$1𐌄.class',
+ \ 'Xspotbugs/tests/𐌂2$1𐌓.class',
+ \ 'Xspotbugs/tests/𐌂2.class']),
+ \ }
+ " No class file for an empty source file even with "-Xpkginfo:always".
+ let results['Xspotbugs/src/tests/package-info.java'] = {
+ \ 'Sourcepath': {-> ''},
+ \ 'classfiles': [],
+ \ }
+ let results['Xspotbugs/src/tests/α/𐌂1.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/𐌂1.java',
+ \ ':p:h:h:S')},
+ \ 'classfiles': sort([
+ \ 'Xspotbugs/tests/α/𐌂1$1.class',
+ \ 'Xspotbugs/tests/α/𐌂1$1𐌉𐌉1.class',
+ \ 'Xspotbugs/tests/α/𐌂1$𐌂11$𐌉𐌉2.class',
+ \ 'Xspotbugs/tests/α/𐌂1$𐌂11.class',
+ \ 'Xspotbugs/tests/α/𐌂1.class',
+ \ 'Xspotbugs/tests/α/𐌂2$1𐌄.class',
+ \ 'Xspotbugs/tests/α/𐌂2$1𐌓.class',
+ \ 'Xspotbugs/tests/α/𐌂2.class']),
+ \ }
+ let results['Xspotbugs/src/tests/α/package-info.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/package-info.java',
+ \ ':p:h:S')},
+ \ 'classfiles': ['Xspotbugs/tests/α/package-info.class'],
+ \ }
+ let results['Xspotbugs/src/tests/α/β/𐌂1.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/𐌂1.java',
+ \ ':p:h:h:h:S')},
+ \ 'classfiles': sort([
+ \ 'Xspotbugs/tests/α/β/𐌂1$1.class',
+ \ 'Xspotbugs/tests/α/β/𐌂1$1𐌉𐌉1.class',
+ \ 'Xspotbugs/tests/α/β/𐌂1$𐌂11$𐌉𐌉2.class',
+ \ 'Xspotbugs/tests/α/β/𐌂1$𐌂11.class',
+ \ 'Xspotbugs/tests/α/β/𐌂1.class',
+ \ 'Xspotbugs/tests/α/β/𐌂2$1𐌄.class',
+ \ 'Xspotbugs/tests/α/β/𐌂2$1𐌓.class',
+ \ 'Xspotbugs/tests/α/β/𐌂2.class']),
+ \ }
+ let results['Xspotbugs/src/tests/α/β/package-info.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/package-info.java',
+ \ ':p:h:S')},
+ \ 'classfiles': ['Xspotbugs/tests/α/β/package-info.class'],
+ \ }
+ let results['Xspotbugs/src/tests/α/β/γ/𐌂1.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/𐌂1.java',
+ \ ':p:h:h:h:h:S')},
+ \ 'classfiles': sort([
+ \ 'Xspotbugs/tests/α/β/γ/𐌂1$1.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂1$1𐌉𐌉1.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂1$𐌂11$𐌉𐌉2.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂1$𐌂11.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂1.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂2$1𐌄.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂2$1𐌓.class',
+ \ 'Xspotbugs/tests/α/β/γ/𐌂2.class']),
+ \ }
+ let results['Xspotbugs/src/tests/α/β/γ/package-info.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/package-info.java',
+ \ ':p:h:S')},
+ \ 'classfiles': ['Xspotbugs/tests/α/β/γ/package-info.class'],
+ \ }
+ let results['Xspotbugs/src/tests/α/β/γ/δ/𐌂1.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/δ/𐌂1.java',
+ \ ':p:h:h:h:h:h:S')},
+ \ 'classfiles': sort([
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$1.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$1𐌉𐌉1.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$𐌂11$𐌉𐌉2.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1$𐌂11.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂1.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂2$1𐌄.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂2$1𐌓.class',
+ \ 'Xspotbugs/tests/α/β/γ/δ/𐌂2.class']),
+ \ }
+ let results['Xspotbugs/src/tests/α/β/γ/δ/package-info.java'] = {
+ \ 'Sourcepath': {-> fnamemodify('Xspotbugs/src/tests/α/β/γ/δ/package-info.java',
+ \ ':p:h:S')},
+ \ 'classfiles': ['Xspotbugs/tests/α/β/γ/δ/package-info.class'],
+ \ }
+
+ " MAKE CLASS FILES DISCOVERABLE!
+ let g:spotbugs_properties = {
+ \ 'sourceDirPath': ['src/tests'],
+ \ 'classDirPath': ['tests'],
+ \ }
+
+ call assert_true(has_key(s:SpotBugsParseFilterMakePrg('Xspotbugs', ''), 'sourcepath'))
+ call assert_true(has_key(s:SpotBugsParseFilterMakePrg('Xspotbugs', ''), 'classfiles'))
+
+ " Write 45 mock-up class files for 10 source files.
+ for [class_dir, src_dir, package] in [
+ \ ['Xspotbugs/tests/', 'Xspotbugs/src/tests/', ''],
+ \ ['Xspotbugs/tests/α/', 'Xspotbugs/src/tests/α/', 'package α;'],
+ \ ['Xspotbugs/tests/α/β/', 'Xspotbugs/src/tests/α/β/', 'package α.β;'],
+ \ ['Xspotbugs/tests/α/β/γ/', 'Xspotbugs/src/tests/α/β/γ/', 'package α.β.γ;'],
+ \ ['Xspotbugs/tests/α/β/γ/δ/', 'Xspotbugs/src/tests/α/β/γ/δ/', 'package α.β.γ.δ;']]
+ for class_file in ['𐌂1$1.class', '𐌂1$1𐌉𐌉1.class', '𐌂1$𐌂11$𐌉𐌉2.class',
+ \ '𐌂1$𐌂11.class', '𐌂1.class', '𐌂2$1𐌄.class', '𐌂2$1𐌓.class', '𐌂2.class']
+ call writefile(0zcafe.babe.0000.0041, class_dir .. class_file)
+ endfor
+ call writefile(0zcafe.babe.0000.0041, class_dir .. 'package-info.class')
+
+ " Write Java source files.
+ let type_file = src_dir .. '𐌂1.java'
+ call writefile(insert(copy(lines), package), type_file)
+ let package_file = src_dir .. 'package-info.java'
+ call writefile([package], src_dir .. 'package-info.java')
+
+ " Note that using "off" for the first _outer_ iteration is preferable
+ " because only then "hlexists()" may be 0 (see "compiler/spotbugs.vim").
+ for s in ['off', 'on']
+ execute 'syntax ' .. s
+
+ execute 'edit ' .. type_file
+ compiler spotbugs
+ let result = s:SpotBugsParseFilterMakePrg('Xspotbugs', &l:makeprg)
+ call assert_equal(results[type_file].Sourcepath(), result.sourcepath)
+ call assert_equal(results[type_file].classfiles, result.classfiles)
+ bwipeout
+
+ execute 'edit ' .. package_file
+ compiler spotbugs
+ let result = s:SpotBugsParseFilterMakePrg('Xspotbugs', &l:makeprg)
+ call assert_equal(results[package_file].Sourcepath(), result.sourcepath)
+ call assert_equal(results[package_file].classfiles, result.classfiles)
+ bwipeout
+ endfor
+ endfor
+
+ let &shellslash = save_shellslash
+endfunc
+
+func s:SpotBugsBeforeFileTypeTryPluginAndClearCache(state)
+ " Ponder over "extend(spotbugs#DefaultProperties(), g:spotbugs_properties)"
+ " in "ftplugin/java.vim".
+ let g:spotbugs#state = a:state
+ runtime autoload/spotbugs.vim
+endfunc
+
+func Test_compiler_spotbugs_properties()
+ let save_shellslash = &shellslash
+ set shellslash
+ setlocal makeprg=
+ filetype plugin on
+
+ call assert_true(mkdir('Xspotbugs/src', 'pR'))
+ call assert_true(mkdir('Xspotbugs/tests', 'pR'))
+ let type_file = 'Xspotbugs/src/𐌄.java'
+ let test_file = 'Xspotbugs/tests/𐌄$.java'
+ call writefile(['enum 𐌄{}'], type_file)
+ call writefile(['class 𐌄${}'], test_file)
+
+ " TEST INTEGRATION WITH A BOGUS COMPILER PLUGIN.
+ if !filereadable($VIMRUNTIME .. '/compiler/foo.vim') && !executable('foo')
+ let g:spotbugs_properties = {'compiler': 'foo'}
+ " XXX: In case this "if" block is no longer first.
+ call s:SpotBugsBeforeFileTypeTryPluginAndClearCache({
+ \ 'compiler': g:spotbugs_properties.compiler,
+ \ })
+ execute 'edit ' .. type_file
+ call assert_equal('java', &l:filetype)
+ " This variable will indefinitely keep the compiler name.
+ call assert_equal('foo', g:spotbugs#state.compiler)
+ " The "compiler" entry should be gone after FileType and default entries
+ " should only appear for a supported compiler.
+ call assert_false(has_key(g:spotbugs_properties, 'compiler'))
+ call assert_true(empty(g:spotbugs_properties))
+ " Query default implementations.
+ call assert_true(exists('*spotbugs#DefaultProperties'))
+ call assert_true(exists('*spotbugs#DefaultPreCompilerAction'))
+ call assert_true(exists('*spotbugs#DefaultPreCompilerTestAction'))
+ call assert_true(empty(spotbugs#DefaultProperties()))
+ " Get a ":message".
+ redir => out
+ call spotbugs#DefaultPreCompilerAction()
+ redir END
+ call assert_equal('Not supported: "foo"', out[stridx(out, 'Not') :])
+ " Get a ":message".
+ redir => out
+ call spotbugs#DefaultPreCompilerTestAction()
+ redir END
+ call assert_equal('Not supported: "foo"', out[stridx(out, 'Not') :])
+ " No ":autocmd"s without one of "PreCompiler*Action", "PostCompilerAction".
+ call assert_false(exists('#java_spotbugs'))
+ bwipeout
+ endif
+
+ let s:spotbugs_results = {
+ \ 'preActionDone': 0,
+ \ 'preTestActionDone': 0,
+ \ 'preTestLocalActionDone': 0,
+ \ 'postActionDone': 0,
+ \ 'preCommandArguments': '',
+ \ 'preTestCommandArguments': '',
+ \ 'postCommandArguments': '',
+ \ }
+ defer execute('unlet s:spotbugs_results')
+
+ func! g:SpotBugsPreAction() abort
+ let s:spotbugs_results.preActionDone = 1
+ " XXX: Notify the spotbugs compiler about success or failure.
+ cc
+ endfunc
+ defer execute('delfunction g:SpotBugsPreAction')
+
+ func! g:SpotBugsPreTestAction() abort
+ let s:spotbugs_results.preTestActionDone = 1
+ " XXX: Let see compilation fail.
+ throw 'Oops'
+ endfunc
+ defer execute('delfunction g:SpotBugsPreTestAction')
+
+ func! g:SpotBugsPreTestLocalAction() abort
+ let s:spotbugs_results.preTestLocalActionDone = 1
+ " XXX: Notify the spotbugs compiler about success or failure.
+ cc
+ endfunc
+ defer execute('delfunction g:SpotBugsPreTestLocalAction')
+
+ func! g:SpotBugsPostAction() abort
+ let s:spotbugs_results.postActionDone = 1
+ endfunc
+ defer execute('delfunction g:SpotBugsPostAction')
+
+ func! g:SpotBugsPreCommand(arguments) abort
+ let s:spotbugs_results.preActionDone = 1
+ let s:spotbugs_results.preCommandArguments = a:arguments
+ " XXX: Notify the spotbugs compiler about success or failure.
+ cc
+ endfunc
+ defer execute('delfunction g:SpotBugsPreCommand')
+
+ func! g:SpotBugsPreTestCommand(arguments) abort
+ let s:spotbugs_results.preTestActionDone = 1
+ let s:spotbugs_results.preTestCommandArguments = a:arguments
+ " XXX: Notify the spotbugs compiler about success or failure.
+ cc
+ endfunc
+ defer execute('delfunction g:SpotBugsPreTestCommand')
+
+ func! g:SpotBugsPostCommand(arguments) abort
+ let s:spotbugs_results.postActionDone = 1
+ let s:spotbugs_results.postCommandArguments = a:arguments
+ endfunc
+ defer execute('delfunction g:SpotBugsPostCommand')
+
+ func! g:SpotBugsPostCompilerActionExecutor(action) abort
+ try
+ " XXX: Notify the spotbugs compiler about success or failure.
+ cc
+ catch /\<E42:/
+ execute a:action
+ endtry
+ endfunc
+ defer execute('delfunction g:SpotBugsPostCompilerActionExecutor')
+
+ " TEST INTEGRATION WITH A SUPPORTED COMPILER PLUGIN.
+ if filereadable($VIMRUNTIME .. '/compiler/maven.vim')
+ let save_PATH = $PATH
+ if !executable('mvn')
+ if has('win32')
+ let $PATH = 'Xspotbugs;' .. $PATH
+ " This is what ":help executable()" suggests.
+ call writefile([], 'Xspotbugs/mvn.cmd')
+ else
+ let $PATH = 'Xspotbugs:' .. $PATH
+ call writefile([], 'Xspotbugs/mvn')
+ call setfperm('Xspotbugs/mvn', 'rwx------')
+ endif
+ endif
+
+ let g:spotbugs_properties = {
+ \ 'compiler': 'maven',
+ \ 'PreCompilerAction': function('g:SpotBugsPreAction'),
+ \ 'PreCompilerTestAction': function('g:SpotBugsPreTestAction'),
+ \ 'PostCompilerAction': function('g:SpotBugsPostAction'),
+ \ }
+ " XXX: In case this is a runner-up ":edit".
+ call s:SpotBugsBeforeFileTypeTryPluginAndClearCache({
+ \ 'compiler': g:spotbugs_properties.compiler,
+ \ })
+ execute 'edit ' .. type_file
+ call assert_equal('java', &l:filetype)
+ call assert_equal('maven', g:spotbugs#state.compiler)
+ call assert_false(has_key(g:spotbugs_properties, 'compiler'))
+ call assert_false(empty(g:spotbugs_properties))
+ " Query default implementations.
+ call assert_true(exists('*spotbugs#DefaultProperties'))
+ call assert_equal(sort([
+ \ 'PreCompilerAction',
+ \ 'PreCompilerTestAction',
+ \ 'PostCompilerAction',
+ \ 'sourceDirPath',
+ \ 'classDirPath',
+ \ 'testSourceDirPath',
+ \ 'testClassDirPath',
+ \ ]),
+ \ sort(keys(spotbugs#DefaultProperties())))
+ " Some ":autocmd"s with one of "PreCompiler*Action", "PostCompilerAction".
+ call assert_true(exists('#java_spotbugs'))
+ call assert_true(exists('#java_spotbugs#Syntax'))
+ call assert_true(exists('#java_spotbugs#User'))
+ call assert_equal(2, exists(':SpotBugsDefineBufferAutocmd'))
+ " SpotBugsDefineBufferAutocmd SigUSR1 User SigUSR1 User SigUSR1 User
+ " call assert_true(exists('#java_spotbugs#SigUSR1'))
+ SpotBugsDefineBufferAutocmd Signal User Signal User Signal User
+ call assert_true(exists('#java_spotbugs#Signal'))
+ call assert_true(exists('#java_spotbugs#Syntax'))
+ call assert_true(exists('#java_spotbugs#User'))
+ call assert_equal(2, exists(':SpotBugsRemoveBufferAutocmd'))
+ " SpotBugsRemoveBufferAutocmd SigUSR1 User SigUSR1 User UserGettingBored
+ " call assert_false(exists('#java_spotbugs#SigUSR1'))
+ SpotBugsRemoveBufferAutocmd Signal User Signal User UserGettingBored
+ call assert_false(exists('#java_spotbugs#Signal'))
+ call assert_true(exists('#java_spotbugs#Syntax'))
+ call assert_true(exists('#java_spotbugs#User'))
+
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+
+ doautocmd java_spotbugs Syntax
+ call assert_false(exists('#java_spotbugs#Syntax'))
+
+ " No match: "type_file !~# 'src/main/java'".
+ call assert_false(s:spotbugs_results.preActionDone)
+ " No match: "type_file !~# 'src/test/java'".
+ call assert_false(s:spotbugs_results.preTestActionDone)
+ " No pre-match, no post-action.
+ call assert_false(s:spotbugs_results.postActionDone)
+ " Without a match, confirm that ":compiler spotbugs" has NOT run.
+ call assert_true(empty(&l:makeprg))
+
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+ " Update path entries. (Note that we cannot use just "src" because there
+ " is another "src" directory nearer the filesystem root directory, i.e.
+ " "vim/vim/src/testdir/Xspotbugs/src", and "s:DispatchAction()" (see
+ " "ftplugin/java.vim") will match "vim/vim/src/testdir/Xspotbugs/tests"
+ " against "src".)
+ let g:spotbugs_properties.sourceDirPath = ['Xspotbugs/src']
+ let g:spotbugs_properties.classDirPath = ['Xspotbugs/src']
+ let g:spotbugs_properties.testSourceDirPath = ['tests']
+ let g:spotbugs_properties.testClassDirPath = ['tests']
+
+ doautocmd java_spotbugs User
+ " No match: "type_file !~# 'src/main/java'" (with old "*DirPath" values
+ " cached).
+ call assert_false(s:spotbugs_results.preActionDone)
+ " No match: "type_file !~# 'src/test/java'" (with old "*DirPath" values
+ " cached).
+ call assert_false(s:spotbugs_results.preTestActionDone)
+ " No pre-match, no post-action.
+ call assert_false(s:spotbugs_results.postActionDone)
+ " Without a match, confirm that ":compiler spotbugs" has NOT run.
+ call assert_true(empty(&l:makeprg))
+
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+ " XXX: Re-build ":autocmd"s from scratch with new values applied.
+ doautocmd FileType
+
+ call assert_true(exists('b:spotbugs_syntax_once'))
+ doautocmd java_spotbugs User
+ " A match: "type_file =~# 'Xspotbugs/src'" (with new "*DirPath" values
+ " cached).
+ call assert_true(s:spotbugs_results.preActionDone)
+ " No match: "type_file !~# 'tests'" (with new "*DirPath" values cached).
+ call assert_false(s:spotbugs_results.preTestActionDone)
+ " For a pre-match, a post-action.
+ call assert_true(s:spotbugs_results.postActionDone)
+
+ " With a match, confirm that ":compiler spotbugs" has run.
+ if has('win32')
+ call assert_match('^spotbugs\.bat\s', &l:makeprg)
+ else
+ call assert_match('^spotbugs\s', &l:makeprg)
+ endif
+
+ bwipeout
+ setlocal makeprg=
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionDone = 0
+ let s:spotbugs_results.preTestLocalActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+
+ execute 'edit ' .. test_file
+ " Prepare a buffer-local, incomplete variant of properties, relying on
+ " "ftplugin/java.vim" to take care of merging in unique entries, if any,
+ " from "g:spotbugs_properties".
+ let b:spotbugs_properties = {
+ \ 'PreCompilerTestAction': function('g:SpotBugsPreTestLocalAction'),
+ \ }
+ call assert_equal('java', &l:filetype)
+ call assert_true(exists('#java_spotbugs'))
+ call assert_true(exists('#java_spotbugs#Syntax'))
+ call assert_true(exists('#java_spotbugs#User'))
+ call assert_fails('doautocmd java_spotbugs Syntax', 'Oops')
+ call assert_false(exists('#java_spotbugs#Syntax'))
+ " No match: "test_file !~# 'Xspotbugs/src'".
+ call assert_false(s:spotbugs_results.preActionDone)
+ " A match: "test_file =~# 'tests'".
+ call assert_true(s:spotbugs_results.preTestActionDone)
+ call assert_false(s:spotbugs_results.preTestLocalActionDone)
+ " No action after pre-failure (the thrown "Oops" doesn't qualify for ":cc").
+ call assert_false(s:spotbugs_results.postActionDone)
+ " No ":compiler spotbugs" will be run after pre-failure.
+ call assert_true(empty(&l:makeprg))
+
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionDone = 0
+ let s:spotbugs_results.preTestLocalActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+ " XXX: Re-build ":autocmd"s from scratch with buffer-local values applied.
+ doautocmd FileType
+
+ call assert_true(exists('b:spotbugs_syntax_once'))
+ doautocmd java_spotbugs User
+ " No match: "test_file !~# 'Xspotbugs/src'".
+ call assert_false(s:spotbugs_results.preActionDone)
+ " A match: "test_file =~# 'tests'".
+ call assert_true(s:spotbugs_results.preTestLocalActionDone)
+ call assert_false(s:spotbugs_results.preTestActionDone)
+ " For a pre-match, a post-action.
+ call assert_true(s:spotbugs_results.postActionDone)
+
+ " With a match, confirm that ":compiler spotbugs" has run.
+ if has('win32')
+ call assert_match('^spotbugs\.bat\s', &l:makeprg)
+ else
+ call assert_match('^spotbugs\s', &l:makeprg)
+ endif
+
+ setlocal makeprg=
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionDone = 0
+ let s:spotbugs_results.preTestLocalActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+ let s:spotbugs_results.preCommandArguments = ''
+ let s:spotbugs_results.preTestCommandArguments = ''
+ let s:spotbugs_results.postCommandArguments = ''
+ " XXX: Compose the assigned "*Command"s with the default Maven "*Action"s.
+ let b:spotbugs_properties = {
+ \ 'compiler': 'maven',
+ \ 'DefaultPreCompilerTestCommand': function('g:SpotBugsPreTestCommand'),
+ \ 'DefaultPreCompilerCommand': function('g:SpotBugsPreCommand'),
+ \ 'DefaultPostCompilerCommand': function('g:SpotBugsPostCommand'),
+ \ 'PostCompilerActionExecutor': function('g:SpotBugsPostCompilerActionExecutor'),
+ \ 'augroupForPostCompilerAction': 'java_spotbugs_test',
+ \ 'sourceDirPath': ['Xspotbugs/src'],
+ \ 'classDirPath': ['Xspotbugs/src'],
+ \ 'testSourceDirPath': ['tests'],
+ \ 'testClassDirPath': ['tests'],
+ \ }
+ unlet g:spotbugs_properties
+ " XXX: Re-build ":autocmd"s from scratch with buffer-local values applied.
+ call s:SpotBugsBeforeFileTypeTryPluginAndClearCache({
+ \ 'compiler': b:spotbugs_properties.compiler,
+ \ 'commands': {
+ \ 'DefaultPreCompilerTestCommand':
+ \ b:spotbugs_properties.DefaultPreCompilerTestCommand,
+ \ 'DefaultPreCompilerCommand':
+ \ b:spotbugs_properties.DefaultPreCompilerCommand,
+ \ 'DefaultPostCompilerCommand':
+ \ b:spotbugs_properties.DefaultPostCompilerCommand,
+ \ },
+ \ })
+ doautocmd FileType
+
+ call assert_equal('maven', g:spotbugs#state.compiler)
+ call assert_equal(sort([
+ \ 'DefaultPreCompilerTestCommand',
+ \ 'DefaultPreCompilerCommand',
+ \ 'DefaultPostCompilerCommand',
+ \ ]),
+ \ sort(keys(g:spotbugs#state.commands)))
+ call assert_true(exists('b:spotbugs_syntax_once'))
+ doautocmd java_spotbugs User
+ " No match: "test_file !~# 'Xspotbugs/src'".
+ call assert_false(s:spotbugs_results.preActionDone)
+ call assert_true(empty(s:spotbugs_results.preCommandArguments))
+ " A match: "test_file =~# 'tests'".
+ call assert_true(s:spotbugs_results.preTestActionDone)
+ call assert_equal('test-compile', s:spotbugs_results.preTestCommandArguments)
+ " For a pre-match, a post-action.
+ call assert_true(s:spotbugs_results.postActionDone)
+ call assert_equal('%:S', s:spotbugs_results.postCommandArguments)
+
+ " With a match, confirm that ":compiler spotbugs" has run.
+ if has('win32')
+ call assert_match('^spotbugs\.bat\s', &l:makeprg)
+ else
+ call assert_match('^spotbugs\s', &l:makeprg)
+ endif
+
+ setlocal makeprg=
+ let s:spotbugs_results.preActionDone = 0
+ let s:spotbugs_results.preTestActionOtherDone = 0
+ let s:spotbugs_results.preTestLocalActionDone = 0
+ let s:spotbugs_results.postActionDone = 0
+ let s:spotbugs_results.preCommandArguments = ''
+ let s:spotbugs_results.preTestCommandArguments = ''
+ let s:spotbugs_results.postCommandArguments = ''
+
+ " When "PostCompilerActionExecutor", "Pre*Action" and/or "Pre*TestAction",
+ " and "Post*Action" are available, "#java_spotbugs_post" must be defined.
+ call assert_true(exists('#java_spotbugs_post'))
+ call assert_true(exists('#java_spotbugs_post#User'))
+ call assert_false(exists('#java_spotbugs_post#ShellCmdPost'))
+ call assert_false(exists('#java_spotbugs_test#ShellCmdPost'))
+
+ " Re-link a Funcref on the fly.
+ func! g:SpotBugsPreTestCommand(arguments) abort
+ let s:spotbugs_results.preTestActionOtherDone = 1
+ let s:spotbugs_results.preTestCommandArguments = a:arguments
+ " Define a once-only ":autocmd" for "#java_spotbugs_test#ShellCmdPost".
+ doautocmd java_spotbugs_post User
+ " XXX: Do NOT use ":cc" to notify the spotbugs compiler about success or
+ " failure, and assume the transfer of control to a ShellCmdPost command.
+ endfunc
+
+ doautocmd java_spotbugs User
+ " No match: "test_file !~# 'Xspotbugs/src'".
+ call assert_false(s:spotbugs_results.preActionDone)
+ call assert_true(empty(s:spotbugs_results.preCommandArguments))
+ " A match: "test_file =~# 'tests'".
+ call assert_true(s:spotbugs_results.preTestActionOtherDone)
+ call assert_equal('test-compile', s:spotbugs_results.preTestCommandArguments)
+ " For a pre-match, no post-action (without ":cc") UNLESS a ShellCmdPost
+ " event is consumed whose command will invoke "PostCompilerActionExecutor"
+ " and the latter will accept a post-compiler action argument.
+ call assert_false(s:spotbugs_results.postActionDone)
+ call assert_true(exists('#java_spotbugs_test#ShellCmdPost'))
+ doautocmd ShellCmdPost
+ call assert_false(exists('#java_spotbugs_test#ShellCmdPost'))
+ call assert_true(s:spotbugs_results.postActionDone)
+ call assert_equal('%:S', s:spotbugs_results.postCommandArguments)
+
+ " With a match, confirm that ":compiler spotbugs" has run.
+ if has('win32')
+ call assert_match('^spotbugs\.bat\s', &l:makeprg)
+ else
+ call assert_match('^spotbugs\s', &l:makeprg)
+ endif
+
+ bwipeout
+ setlocal makeprg=
+ let $PATH = save_PATH
+ endif
+
+ filetype plugin off
+ setlocal makeprg=
+ let &shellslash = save_shellslash
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim
index 3a469e8a17..5820b58247 100644
--- a/test/old/testdir/test_debugger.vim
+++ b/test/old/testdir/test_debugger.vim
@@ -6,10 +6,11 @@ source check.vim
func CheckCWD()
" Check that the longer lines don't wrap due to the length of the script name
- " in cwd
+ " in cwd. Need to subtract by 1 since Vim will still wrap the message if it
+ " just fits.
let script_len = len( getcwd() .. '/Xtest1.vim' )
let longest_line = len( 'Breakpoint in "" line 1' )
- if script_len > ( 75 - longest_line )
+ if script_len > ( 75 - longest_line - 1 )
throw 'Skipped: Your CWD has too many characters'
endif
endfunc
diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim
index 880286d329..ab64658bd0 100644
--- a/test/old/testdir/test_diffmode.vim
+++ b/test/old/testdir/test_diffmode.vim
@@ -1017,6 +1017,41 @@ func Test_diff_screen()
call WriteDiffFiles(buf, [], [0])
call VerifyBoth(buf, "Test_diff_22", "")
+ call WriteDiffFiles(buf, ['?a', '?b', '?c'], ['!b'])
+ call VerifyInternal(buf, 'Test_diff_23', " diffopt+=linematch:30")
+
+ call WriteDiffFiles(buf, ['',
+ \ 'common line',
+ \ 'common line',
+ \ '',
+ \ 'DEFabc',
+ \ 'xyz',
+ \ 'xyz',
+ \ 'xyz',
+ \ 'DEFabc',
+ \ 'DEFabc',
+ \ 'DEFabc',
+ \ 'common line',
+ \ 'common line',
+ \ 'DEF',
+ \ 'common line',
+ \ 'DEF',
+ \ 'something' ],
+ \ ['',
+ \ 'common line',
+ \ 'common line',
+ \ '',
+ \ 'ABCabc',
+ \ 'ABCabc',
+ \ 'ABCabc',
+ \ 'ABCabc',
+ \ 'common line',
+ \ 'common line',
+ \ 'common line',
+ \ 'something'])
+ call VerifyInternal(buf, 'Test_diff_24', " diffopt+=linematch:30")
+
+
" clean up
call StopVimInTerminal(buf)
call delete('Xdifile1')
@@ -1212,7 +1247,7 @@ func CloseoffSetup()
call setline(1, ['one', 'tow', 'three'])
diffthis
call assert_equal(1, &diff)
- only!
+ bw!
endfunc
func Test_diff_closeoff()
@@ -2004,6 +2039,12 @@ func Test_diff_overlapped_diff_blocks_will_be_merged()
call WriteDiffFiles3(buf, ["a", "b", "c"], ["a", "x", "c"], ["a", "b", "y", "c"])
call VerifyBoth(buf, "Test_diff_overlapped_3.37", "")
+ call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b", "f"])
+ call VerifyBoth(buf, "Test_diff_overlapped_3.38", "")
+
+ call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b"])
+ call VerifyBoth(buf, "Test_diff_overlapped_3.39", "")
+
call StopVimInTerminal(buf)
endfunc
@@ -2034,4 +2075,440 @@ func Test_diff_topline_noscroll()
call StopVimInTerminal(buf)
endfunc
+func Test_diffget_diffput_linematch()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ " enable linematch
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call WriteDiffFiles(buf, ['',
+ \ 'common line',
+ \ 'common line',
+ \ '',
+ \ 'ABCabc',
+ \ 'ABCabc',
+ \ 'ABCabc',
+ \ 'ABCabc',
+ \ 'common line',
+ \ 'common line',
+ \ 'common line',
+ \ 'something' ],
+ \ ['',
+ \ 'common line',
+ \ 'common line',
+ \ '',
+ \ 'DEFabc',
+ \ 'xyz',
+ \ 'xyz',
+ \ 'xyz',
+ \ 'DEFabc',
+ \ 'DEFabc',
+ \ 'DEFabc',
+ \ 'common line',
+ \ 'common line',
+ \ 'DEF',
+ \ 'common line',
+ \ 'DEF',
+ \ 'something'])
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_1', {})
+
+ " get from window 1 from line 5 to 9
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, ":5,9diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_2', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get from window 2 from line 5 to 10
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, ":5,10diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_3', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get all from window 2
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, ":4,17diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_4', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get all from window 1
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, ":4,12diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_5', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get from window 1 using do 1 line 5
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "5gg")
+ call term_sendkeys(buf, ":diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_6', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get from window 1 using do 2 line 6
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "6gg")
+ call term_sendkeys(buf, ":diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_7', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get from window 1 using do 2 line 7
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "7gg")
+ call term_sendkeys(buf, ":diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_8', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get from window 1 using do 2 line 11
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "11gg")
+ call term_sendkeys(buf, ":diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_9', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " get from window 1 using do 2 line 12
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "12gg")
+ call term_sendkeys(buf, ":diffget\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_10', {})
+
+ " undo the last diffget
+ call term_sendkeys(buf, "u")
+
+ " put from window 1 using dp 1 line 5
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "5gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_11', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 1 using dp 2 line 6
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "6gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_12', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 1 using dp 2 line 7
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "7gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_13', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 1 using dp 2 line 11
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "11gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_14', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 1 using dp 2 line 12
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "12gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_15', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 2 using dp line 6
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "6gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_16', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 2 using dp line 8
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "8gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_17', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 2 using dp line 9
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "9gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_18', {})
+
+ " undo the last diffput
+ call term_sendkeys(buf, "1\<c-w>w")
+ call term_sendkeys(buf, "u")
+
+ " put from window 2 using dp line 17
+ call term_sendkeys(buf, "2\<c-w>w")
+ call term_sendkeys(buf, "17gg")
+ call term_sendkeys(buf, ":diffput\<CR>")
+ call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_19', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_linematch_diff()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ " enable linematch
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call WriteDiffFiles(buf, ['// abc d?',
+ \ '// d?',
+ \ '// d?' ],
+ \ ['!',
+ \ 'abc d!',
+ \ 'd!'])
+ call VerifyScreenDump(buf, 'Test_linematch_diff1', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_linematch_diff_iwhite()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ " setup a diff with 2 files and set linematch:30, with ignore white
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call WriteDiffFiles(buf, ['void testFunction () {',
+ \ ' for (int i = 0; i < 10; i++) {',
+ \ ' for (int j = 0; j < 10; j++) {',
+ \ ' }',
+ \ ' }',
+ \ '}' ],
+ \ ['void testFunction () {',
+ \ ' // for (int j = 0; j < 10; i++) {',
+ \ ' // }',
+ \ '}'])
+ call VerifyScreenDump(buf, 'Test_linematch_diff_iwhite1', {})
+ call term_sendkeys(buf, ":set diffopt+=iwhiteall\<CR>")
+ call VerifyScreenDump(buf, 'Test_linematch_diff_iwhite2', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_linematch_diff_grouping()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ " a diff that would result in multiple groups before grouping optimization
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call WriteDiffFiles(buf, ['!A',
+ \ '!B',
+ \ '!C' ],
+ \ ['?Z',
+ \ '?A',
+ \ '?B',
+ \ '?C',
+ \ '?A',
+ \ '?B',
+ \ '?B',
+ \ '?C'])
+ call VerifyScreenDump(buf, 'Test_linematch_diff_grouping1', {})
+ call WriteDiffFiles(buf, ['!A',
+ \ '!B',
+ \ '!C' ],
+ \ ['?A',
+ \ '?Z',
+ \ '?B',
+ \ '?C',
+ \ '?A',
+ \ '?B',
+ \ '?C',
+ \ '?C'])
+ call VerifyScreenDump(buf, 'Test_linematch_diff_grouping2', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_linematch_diff_scroll()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ " a diff that would result in multiple groups before grouping optimization
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call WriteDiffFiles(buf, ['!A',
+ \ '!B',
+ \ '!C' ],
+ \ ['?A',
+ \ '?Z',
+ \ '?B',
+ \ '?C',
+ \ '?A',
+ \ '?B',
+ \ '?C',
+ \ '?C'])
+ " scroll down to show calculation of top fill and scroll to correct line in
+ " both windows
+ call VerifyScreenDump(buf, 'Test_linematch_diff_grouping_scroll0', {})
+ call term_sendkeys(buf, "3\<c-e>")
+ call VerifyScreenDump(buf, 'Test_linematch_diff_grouping_scroll1', {})
+ call term_sendkeys(buf, "3\<c-e>")
+ call VerifyScreenDump(buf, 'Test_linematch_diff_grouping_scroll2', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_linematch_line_limit_exceeded()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ call term_sendkeys(buf, ":set diffopt+=linematch:10\<CR>")
+ " a diff block will not be aligned with linematch because it's contents
+ " exceed 10 lines
+ call WriteDiffFiles(buf,
+ \ ['common line',
+ \ 'HIL',
+ \ '',
+ \ 'aABCabc',
+ \ 'aABCabc',
+ \ 'aABCabc',
+ \ 'aABCabc',
+ \ 'common line',
+ \ 'HIL',
+ \ 'common line',
+ \ 'something'],
+ \ ['common line',
+ \ 'DEF',
+ \ 'GHI',
+ \ 'something',
+ \ '',
+ \ 'aDEFabc',
+ \ 'xyz',
+ \ 'xyz',
+ \ 'xyz',
+ \ 'aDEFabc',
+ \ 'aDEFabc',
+ \ 'aDEFabc',
+ \ 'common line',
+ \ 'DEF',
+ \ 'GHI',
+ \ 'something else',
+ \ 'common line',
+ \ 'something'])
+ call VerifyScreenDump(buf, 'Test_linematch_line_limit_exceeded1', {})
+ " after increasing the count to 30, the limit is not exceeded, and the
+ " alignment algorithm will run on the largest diff block here
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call VerifyScreenDump(buf, 'Test_linematch_line_limit_exceeded2', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_linematch_3diffs()
+ CheckScreendump
+ call delete('.Xdifile1.swp')
+ call delete('.Xdifile2.swp')
+ call delete('.Xdifile3.swp')
+ call WriteDiffFiles3(0, [], [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2 Xdifile3', {})
+ call term_sendkeys(buf, "1\<c-w>w:set autoread\<CR>")
+ call term_sendkeys(buf, "2\<c-w>w:set autoread\<CR>")
+ call term_sendkeys(buf, "3\<c-w>w:set autoread\<CR>")
+ call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call WriteDiffFiles3(buf,
+ \ ["",
+ \ " common line",
+ \ " AAA",
+ \ " AAA",
+ \ " AAA"],
+ \ ["",
+ \ " common line",
+ \ " <<<<<<< HEAD",
+ \ " AAA",
+ \ " AAA",
+ \ " AAA",
+ \ " =======",
+ \ " BBB",
+ \ " BBB",
+ \ " BBB",
+ \ " >>>>>>> branch1"],
+ \ ["",
+ \ " common line",
+ \ " BBB",
+ \ " BBB",
+ \ " BBB"])
+ call VerifyScreenDump(buf, 'Test_linematch_3diffs1', {})
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+" this used to access invalid memory
+func Test_linematch_3diffs_sanity_check()
+ CheckScreendump
+ call delete('.Xfile_linematch1.swp')
+ call delete('.Xfile_linematch2.swp')
+ call delete('.Xfile_linematch3.swp')
+ let lines =<< trim END
+ set diffopt+=linematch:60
+ call feedkeys("Aq\<esc>")
+ call feedkeys("GAklm\<esc>")
+ call feedkeys("o")
+ END
+ call writefile(lines, 'Xlinematch_3diffs.vim', 'D')
+ call writefile(['abcd', 'def', 'hij'], 'Xfile_linematch1', 'D')
+ call writefile(['defq', 'hijk', 'nopq'], 'Xfile_linematch2', 'D')
+ call writefile(['hijklm', 'nopqr', 'stuv'], 'Xfile_linematch3', 'D')
+ call WriteDiffFiles3(0, [], [], [])
+ let buf = RunVimInTerminal('-d -S Xlinematch_3diffs.vim Xfile_linematch1 Xfile_linematch2 Xfile_linematch3', {})
+ call VerifyScreenDump(buf, 'Test_linematch_3diffs2', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_digraph.vim b/test/old/testdir/test_digraph.vim
index 8fbcd4d8ca..0a71cbba99 100644
--- a/test/old/testdir/test_digraph.vim
+++ b/test/old/testdir/test_digraph.vim
@@ -40,6 +40,9 @@ func Test_digraphs()
" Quadruple prime
call Put_Dig("'4")
call assert_equal("⁗", getline('.'))
+ " APPROACHES THE LIMIT
+ call Put_Dig(".=")
+ call assert_equal("≐", getline('.'))
" Not a digraph
call Put_Dig("a\<bs>")
call Put_Dig("\<bs>a")
@@ -250,9 +253,12 @@ func Test_digraphs_option()
call Put_Dig_BS("P","=")
call assert_equal(['Р']+repeat(["₽"],2)+['П'], getline(line('.')-3,line('.')))
" Not a digraph: this is different from <c-k>!
+ let _bs = &bs
+ set bs=
call Put_Dig_BS("a","\<bs>")
call Put_Dig_BS("\<bs>","a")
call assert_equal(['','a'], getline(line('.')-1,line('.')))
+ let &bs = _bs
" Grave
call Put_Dig_BS("a","!")
call Put_Dig_BS("!","e")
@@ -604,8 +610,10 @@ func Test_digraph_getlist_function()
" of digraphs returned.
call assert_equal(digraph_getlist()->len(), digraph_getlist(0)->len())
call assert_notequal(digraph_getlist()->len(), digraph_getlist(1)->len())
+ call assert_equal(digraph_getlist()->len(), digraph_getlist(v:false)->len())
+ call assert_notequal(digraph_getlist()->len(), digraph_getlist(v:true)->len())
- call assert_fails('call digraph_getlist(0z12)', 'E974: Using a Blob as a Number')
+ call assert_fails('call digraph_getlist(0z12)', 'E1212: Bool required for argument 1')
endfunc
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index 19b7d41552..9398cea786 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -108,12 +108,14 @@ func s:GetFilenameChecks() abort
\ '/etc/httpd/sites-some/file', '/etc/httpd/conf.file/conf'],
\ 'apachestyle': ['/etc/proftpd/file.config,/etc/proftpd/conf.file/file', '/etc/proftpd/conf.file/file', '/etc/proftpd/file.conf', '/etc/proftpd/file.conf-file',
\ 'any/etc/proftpd/conf.file/file', 'any/etc/proftpd/file.conf', 'any/etc/proftpd/file.conf-file', 'proftpd.conf', 'proftpd.conf-file'],
+ \ 'apkbuild': ['APKBUILD'],
\ 'applescript': ['file.scpt'],
\ 'aptconf': ['apt.conf', '/.aptitude/config', 'any/.aptitude/config'],
\ 'arch': ['.arch-inventory', '=tagging-method'],
\ 'arduino': ['file.ino', 'file.pde'],
\ 'art': ['file.art'],
\ 'asciidoc': ['file.asciidoc', 'file.adoc'],
+ \ 'asm': ['file.s', 'file.S', 'file.a', 'file.A'],
\ 'asn': ['file.asn', 'file.asn1'],
\ 'asterisk': ['asterisk/file.conf', 'asterisk/file.conf-file', 'some-asterisk/file.conf', 'some-asterisk/file.conf-file'],
\ 'astro': ['file.astro'],
@@ -144,6 +146,7 @@ func s:GetFilenameChecks() abort
\ 'bzl': ['file.bazel', 'file.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod'],
\ 'bzr': ['bzr_log.any', 'bzr_log.file'],
\ 'c': ['enlightenment/file.cfg', 'file.qc', 'file.c', 'some-enlightenment/file.cfg', 'file.mdh', 'file.epro'],
+ \ 'c3': ['file.c3', 'file.c3i', 'file.c3t'],
\ 'cabal': ['file.cabal'],
\ 'cabalconfig': ['cabal.config', expand("$HOME/.config/cabal/config")] + s:WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'),
\ 'cabalproject': ['cabal.project', 'cabal.project.local'],
@@ -151,6 +154,7 @@ func s:GetFilenameChecks() abort
\ 'calendar': ['calendar', '/.calendar/file', '/share/calendar/any/calendar.file', '/share/calendar/calendar.file', 'any/share/calendar/any/calendar.file', 'any/share/calendar/calendar.file'],
\ 'capnp': ['file.capnp'],
\ 'catalog': ['catalog', 'sgml.catalogfile', 'sgml.catalog', 'sgml.catalog-file'],
+ \ 'cdc': ['file.cdc'],
\ 'cdl': ['file.cdl'],
\ 'cdrdaoconf': ['/etc/cdrdao.conf', '/etc/defaults/cdrdao', '/etc/default/cdrdao', '.cdrdao', 'any/etc/cdrdao.conf', 'any/etc/default/cdrdao', 'any/etc/defaults/cdrdao'],
\ 'cdrtoc': ['file.toc'],
@@ -188,13 +192,13 @@ func s:GetFilenameChecks() abort
\ 'crm': ['file.crm'],
\ 'crontab': ['crontab', 'crontab.file', '/etc/cron.d/file', 'any/etc/cron.d/file'],
\ 'crystal': ['file.cr'],
- \ 'cs': ['file.cs', 'file.csx'],
+ \ 'cs': ['file.cs', 'file.csx', 'file.cake'],
\ 'csc': ['file.csc'],
\ 'csdl': ['file.csdl'],
\ 'csp': ['file.csp', 'file.fdr'],
\ 'css': ['file.css'],
- \ 'cterm': ['file.con'],
\ 'csv': ['file.csv'],
+ \ 'cterm': ['file.con'],
\ 'cucumber': ['file.feature'],
\ 'cuda': ['file.cu', 'file.cuh'],
\ 'cue': ['file.cue'],
@@ -209,11 +213,11 @@ func s:GetFilenameChecks() abort
\ 'dart': ['file.dart', 'file.drt'],
\ 'datascript': ['file.ds'],
\ 'dcd': ['file.dcd'],
+ \ 'deb822sources': ['/etc/apt/sources.list.d/file.sources', 'any/etc/apt/sources.list.d/file.sources'],
\ 'debchangelog': ['changelog.Debian', 'changelog.dch', 'NEWS.Debian', 'NEWS.dch', '/debian/changelog'],
- \ 'debcontrol': ['/debian/control', 'any/debian/control'],
+ \ 'debcontrol': ['/debian/control', 'any/debian/control', 'any/DEBIAN/control'],
\ 'debcopyright': ['/debian/copyright', 'any/debian/copyright'],
\ 'debsources': ['/etc/apt/sources.list', '/etc/apt/sources.list.d/file.list', 'any/etc/apt/sources.list', 'any/etc/apt/sources.list.d/file.list'],
- \ 'deb822sources': ['/etc/apt/sources.list.d/file.sources', 'any/etc/apt/sources.list.d/file.sources'],
\ 'def': ['file.def'],
\ 'denyhosts': ['denyhosts.conf'],
\ 'desc': ['file.desc'],
@@ -271,7 +275,7 @@ func s:GetFilenameChecks() abort
\ 'falcon': ['file.fal'],
\ 'fan': ['file.fan', 'file.fwt'],
\ 'faust': ['file.dsp', 'file.lib'],
- \ 'fennel': ['file.fnl'],
+ \ 'fennel': ['file.fnl', '.fennelrc', 'fennelrc'],
\ 'fetchmail': ['.fetchmailrc'],
\ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'],
\ 'firrtl': ['file.fir'],
@@ -295,12 +299,13 @@ func s:GetFilenameChecks() abort
\ 'gdscript': ['file.gd'],
\ 'gdshader': ['file.gdshader', 'file.shader'],
\ 'gedcom': ['file.ged', 'lltxxxxx.txt', '/tmp/lltmp', '/tmp/lltmp-file', 'any/tmp/lltmp', 'any/tmp/lltmp-file'],
+ \ 'gel': ['file.gel'],
\ 'gemtext': ['file.gmi', 'file.gemini'],
\ 'gift': ['file.gift'],
\ 'gitattributes': ['file.git/info/attributes', '.gitattributes', '/.config/git/attributes', '/etc/gitattributes', '/usr/local/etc/gitattributes', 'some.git/info/attributes'] + s:WhenConfigHome('$XDG_CONFIG_HOME/git/attributes'),
\ 'gitcommit': ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG', 'NOTES_EDITMSG', 'EDIT_DESCRIPTION'],
\ 'gitconfig': ['file.git/config', 'file.git/config.worktree', 'file.git/worktrees/x/config.worktree', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig', '/usr/local/etc/gitconfig', '/etc/gitconfig.d/file', 'any/etc/gitconfig.d/file', '/.gitconfig.d/file', 'any/.config/git/config', 'any/.gitconfig.d/file', 'some.git/config', 'some.git/modules/any/config'] + s:WhenConfigHome('$XDG_CONFIG_HOME/git/config'),
- \ 'gitignore': ['file.git/info/exclude', '.gitignore', '/.config/git/ignore', 'some.git/info/exclude'] + s:WhenConfigHome('$XDG_CONFIG_HOME/git/ignore') + ['.prettierignore'],
+ \ 'gitignore': ['file.git/info/exclude', '.gitignore', '/.config/git/ignore', 'some.git/info/exclude'] + s:WhenConfigHome('$XDG_CONFIG_HOME/git/ignore') + ['.prettierignore', '.fdignore', '/.config/fd/ignore', '.ignore', '.rgignore', '.dockerignore', '.npmignore', '.vscodeignore'],
\ 'gitolite': ['gitolite.conf', '/gitolite-admin/conf/file', 'any/gitolite-admin/conf/file'],
\ 'gitrebase': ['git-rebase-todo'],
\ 'gitsendemail': ['.gitsendemail.msg.xxxxxx'],
@@ -349,11 +354,12 @@ func s:GetFilenameChecks() abort
\ 'hostconf': ['/etc/host.conf', 'any/etc/host.conf'],
\ 'hostsaccess': ['/etc/hosts.allow', '/etc/hosts.deny', 'any/etc/hosts.allow', 'any/etc/hosts.deny'],
\ 'html': ['file.html', 'file.htm', 'file.cshtml', 'file.component.html'],
- \ 'http': ['file.http'],
\ 'htmlm4': ['file.html.m4'],
\ 'httest': ['file.htt', 'file.htb'],
+ \ 'http': ['file.http'],
\ 'hurl': ['file.hurl'],
- \ 'hyprlang': ['hyprlock.conf', 'hyprland.conf', 'hypridle.conf', 'hyprpaper.conf'],
+ \ 'hy': ['file.hy', '.hy-history'],
+ \ 'hyprlang': ['hyprlock.conf', 'hyprland.conf', 'hypridle.conf', 'hyprpaper.conf', '/hypr/foo.conf'],
\ 'i3config': ['/home/user/.i3/config', '/home/user/.config/i3/config', '/etc/i3/config', '/etc/xdg/i3/config'],
\ 'ibasic': ['file.iba', 'file.ibi'],
\ 'icemenu': ['/.icewm/menu', 'any/.icewm/menu'],
@@ -372,7 +378,7 @@ func s:GetFilenameChecks() abort
\ 'jal': ['file.jal', 'file.JAL'],
\ 'jam': ['file.jpl', 'file.jpr', 'JAM-file.file', 'JAM.file', 'Prl-file.file', 'Prl.file'],
\ 'janet': ['file.janet'],
- \ 'java': ['file.java', 'file.jav'],
+ \ 'java': ['file.java', 'file.jav', 'file.jsh'],
\ 'javacc': ['file.jj', 'file.jjt'],
\ 'javascript': ['file.js', 'file.jsm', 'file.javascript', 'file.es', 'file.mjs', 'file.cjs', '.node_repl_history', '.bun_repl_history', 'deno_history.txt'],
\ 'javascript.glimmer': ['file.gjs'],
@@ -380,18 +386,19 @@ func s:GetFilenameChecks() abort
\ 'jess': ['file.clp'],
\ 'jgraph': ['file.jgr'],
\ 'jinja': ['file.jinja'],
- \ 'jj': ['file.jjdescription'],
- \ 'jq': ['file.jq'],
+ \ 'jjdescription': ['file.jjdescription'],
\ 'jovial': ['file.jov', 'file.j73', 'file.jovial'],
\ 'jproperties': ['file.properties', 'file.properties_xx', 'file.properties_xx_xx', 'some.properties_xx_xx_file', 'org.eclipse.xyz.prefs'],
- \ 'json': ['file.json', 'file.jsonp', 'file.json-patch', 'file.geojson', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb', 'file.jupyterlab-settings', '.prettierrc', '.firebaserc', '.stylelintrc', '.lintstagedrc', 'file.slnf', 'file.sublime-project', 'file.sublime-settings', 'file.sublime-workspace', 'file.bd', 'file.bda', 'file.xci', 'flake.lock', 'pack.mcmeta', 'deno.lock'],
+ \ 'jq': ['file.jq'],
+ \ 'json': ['file.json', 'file.jsonp', 'file.json-patch', 'file.geojson', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb', 'file.jupyterlab-settings', '.prettierrc', '.firebaserc', '.stylelintrc', '.lintstagedrc', 'file.slnf', 'file.sublime-project', 'file.sublime-settings', 'file.sublime-workspace', 'file.bd', 'file.bda', 'file.xci', 'flake.lock', 'pack.mcmeta', 'deno.lock', '.swcrc'],
\ 'json5': ['file.json5'],
- \ 'jsonc': ['file.jsonc', '.babelrc', '.eslintrc', '.jsfmtrc', '.jshintrc', '.jscsrc', '.vsconfig', '.hintrc', '.swrc', 'jsconfig.json', 'tsconfig.json', 'tsconfig.test.json', 'tsconfig-test.json', '.luaurc'],
+ \ 'jsonc': ['file.jsonc', '.babelrc', '.eslintrc', '.jsfmtrc', '.jshintrc', '.jscsrc', '.vsconfig', '.hintrc', '.swrc', 'jsconfig.json', 'tsconfig.json', 'tsconfig.test.json', 'tsconfig-test.json', '.luaurc', 'bun.lock', expand("$HOME/.config/VSCodium/User/settings.json")],
\ 'jsonl': ['file.jsonl'],
\ 'jsonnet': ['file.jsonnet', 'file.libsonnet'],
\ 'jsp': ['file.jsp'],
\ 'julia': ['file.jl'],
\ 'just': ['justfile', 'Justfile', '.justfile', 'config.just'],
+ \ 'karel': ['file.kl', 'file.KL'],
\ 'kconfig': ['Kconfig', 'Kconfig.debug', 'Kconfig.file', 'Config.in', 'Config.in.host'],
\ 'kdl': ['file.kdl'],
\ 'kivy': ['file.kv'],
@@ -401,14 +408,15 @@ func s:GetFilenameChecks() abort
\ 'kscript': ['file.ks'],
\ 'kwt': ['file.k'],
\ 'lace': ['file.ace', 'file.ACE'],
+ \ 'lalrpop': ['file.lalrpop'],
\ 'latte': ['file.latte', 'file.lte'],
\ 'ld': ['file.ld', 'any/usr/lib/aarch64-xilinx-linux/ldscripts/aarch64elf32b.x'],
\ 'ldapconf': ['ldap.conf', '.ldaprc', 'ldaprc'],
\ 'ldif': ['file.ldif'],
\ 'lean': ['file.lean'],
\ 'ledger': ['file.ldg', 'file.ledger', 'file.journal'],
- \ 'less': ['file.less'],
\ 'leo': ['file.leo'],
+ \ 'less': ['file.less'],
\ 'lex': ['file.lex', 'file.l', 'file.lxx', 'file.l++'],
\ 'lf': ['lfrc'],
\ 'lftp': ['lftp.conf', '.lftprc', 'anylftp/rc', 'lftp/rc', 'some-lftp/rc'],
@@ -419,13 +427,13 @@ func s:GetFilenameChecks() abort
\ 'lilo': ['lilo.conf', 'lilo.conf-file'],
\ 'lilypond': ['file.ly', 'file.ily'],
\ 'limits': ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf', '/etc/limits.conf', '/etc/limits.d/file.conf', '/etc/some-limits.conf', '/etc/some-limits.d/file.conf', 'any/etc/limits', 'any/etc/limits.conf', 'any/etc/limits.d/file.conf', 'any/etc/some-limits.conf', 'any/etc/some-limits.d/file.conf'],
- \ 'liquidsoap': ['file.liq'],
\ 'liquid': ['file.liquid'],
- \ 'lisp': ['file.lsp', 'file.lisp', 'file.asd', 'file.el', 'file.cl', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc', 'file.stsg', 'any/local/share/supertux2/config'],
+ \ 'liquidsoap': ['file.liq'],
+ \ 'lisp': ['file.lsp', 'file.lisp', 'file.asd', 'file.el', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc'],
\ 'lite': ['file.lite', 'file.lt'],
\ 'litestep': ['/LiteStep/any/file.rc', 'any/LiteStep/any/file.rc'],
- \ 'logcheck': ['/etc/logcheck/file.d-some/file', '/etc/logcheck/file.d/file', 'any/etc/logcheck/file.d-some/file', 'any/etc/logcheck/file.d/file'],
\ 'livebook': ['file.livemd'],
+ \ 'logcheck': ['/etc/logcheck/file.d-some/file', '/etc/logcheck/file.d/file', 'any/etc/logcheck/file.d-some/file', 'any/etc/logcheck/file.d/file'],
\ 'loginaccess': ['/etc/login.access', 'any/etc/login.access'],
\ 'logindefs': ['/etc/login.defs', 'any/etc/login.defs'],
\ 'logtalk': ['file.lgt'],
@@ -448,9 +456,9 @@ func s:GetFilenameChecks() abort
\ 'mallard': ['file.page'],
"\ 'man': ['file.man'],
\ 'manconf': ['/etc/man.conf', 'man.config', 'any/etc/man.conf'],
- \ 'map': ['file.map'],
\ 'maple': ['file.mv', 'file.mpl', 'file.mws'],
\ 'markdown': ['file.markdown', 'file.mdown', 'file.mkd', 'file.mkdn', 'file.mdwn', 'file.md'],
+ \ 'masm': ['file.masm'],
\ 'mason': ['file.mason', 'file.mhtml'],
\ 'master': ['file.mas', 'file.master'],
\ 'matlab': ['file.m'],
@@ -496,6 +504,7 @@ func s:GetFilenameChecks() abort
\ 'mmp': ['file.mmp'],
\ 'modconf': ['/etc/modules.conf', '/etc/modules', '/etc/conf.modules', '/etc/modprobe.file', 'any/etc/conf.modules', 'any/etc/modprobe.file', 'any/etc/modules', 'any/etc/modules.conf'],
\ 'modula3': ['file.m3', 'file.mg', 'file.i3', 'file.ig', 'file.lm3'],
+ \ 'mojo': ['file.mojo', 'file.🔥'],
\ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'],
\ 'moo': ['file.moo'],
\ 'moonscript': ['file.moon'],
@@ -504,10 +513,9 @@ func s:GetFilenameChecks() abort
\ 'mplayerconf': ['mplayer.conf', '/.mplayer/config', 'any/.mplayer/config'],
\ 'mrxvtrc': ['mrxvtrc', '.mrxvtrc'],
\ 'msidl': ['file.odl', 'file.mof'],
- \ 'mss': ['file.mss'],
- \ 'msql': ['file.msql'],
- \ 'mojo': ['file.mojo', 'file.🔥'],
\ 'msmtp': ['.msmtprc'],
+ \ 'msql': ['file.msql'],
+ \ 'mss': ['file.mss'],
\ 'mupad': ['file.mu'],
\ 'mush': ['file.mush'],
\ 'mustache': ['file.mustache'],
@@ -527,6 +535,7 @@ func s:GetFilenameChecks() abort
\ 'n1ql': ['file.n1ql', 'file.nql'],
\ 'named': ['namedfile.conf', 'rndcfile.conf', 'named-file.conf', 'named.conf', 'rndc-file.conf', 'rndc-file.key', 'rndc.conf', 'rndc.key'],
\ 'nanorc': ['/etc/nanorc', 'file.nanorc', 'any/etc/nanorc'],
+ \ 'nasm': ['file.nasm'],
\ 'natural': ['file.NSA', 'file.NSC', 'file.NSG', 'file.NSL', 'file.NSM', 'file.NSN', 'file.NSP', 'file.NSS'],
\ 'ncf': ['file.ncf'],
\ 'neomuttlog': ['/home/user/.neomuttdebug1'],
@@ -540,6 +549,7 @@ func s:GetFilenameChecks() abort
\ 'nqc': ['file.nqc'],
\ 'nroff': ['file.tr', 'file.nr', 'file.roff', 'file.tmac', 'file.mom', 'tmac.file'],
\ 'nsis': ['file.nsi', 'file.nsh'],
+ \ 'ntriples': ['file.nt'],
\ 'nu': ['file.nu'],
\ 'obj': ['file.obj'],
\ 'objdump': ['file.objdump', 'file.cppobjdump'],
@@ -599,16 +609,18 @@ func s:GetFilenameChecks() abort
\ 'promela': ['file.pml'],
\ 'proto': ['file.proto'],
\ 'protocols': ['/etc/protocols', 'any/etc/protocols'],
+ \ 'prql': ['file.prql'],
\ 'ps1': ['file.ps1', 'file.psd1', 'file.psm1', 'file.pssc'],
\ 'ps1xml': ['file.ps1xml'],
\ 'psf': ['file.psf'],
\ 'psl': ['file.psl'],
+ \ 'ptx': ['file.ptx'],
\ 'pug': ['file.pug'],
\ 'puppet': ['file.pp'],
\ 'purescript': ['file.purs'],
\ 'pymanifest': ['MANIFEST.in'],
\ 'pyret': ['file.arr'],
- \ 'pyrex': ['file.pyx', 'file.pxd'],
+ \ 'pyrex': ['file.pyx', 'file.pxd', 'file.pxi', 'file.pyx+'],
\ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', '.python_history', '.jline-jython.history', 'file.ptl', 'file.pyi', 'SConstruct'],
\ 'ql': ['file.ql', 'file.qll'],
\ 'qml': ['file.qml', 'file.qbs'],
@@ -640,27 +652,27 @@ func s:GetFilenameChecks() abort
\ 'rnc': ['file.rnc'],
\ 'rng': ['file.rng'],
\ 'rnoweb': ['file.rnw', 'file.snw'],
- \ 'rpgle': ['file.rpgle', 'file.rpgleinc'],
\ 'robot': ['file.robot', 'file.resource'],
\ 'robots': ['robots.txt'],
\ 'roc': ['file.roc'],
\ 'ron': ['file.ron'],
\ 'routeros': ['file.rsc'],
\ 'rpcgen': ['file.x'],
+ \ 'rpgle': ['file.rpgle', 'file.rpgleinc'],
\ 'rpl': ['file.rpl'],
\ 'rrst': ['file.rrst', 'file.srst'],
\ 'rst': ['file.rst'],
\ 'rtf': ['file.rtf'],
\ 'ruby': ['.irbrc', 'irbrc', '.irb_history', 'irb_history', 'file.rb', 'file.rbw', 'file.gemspec', 'file.ru', 'Gemfile', 'file.builder', 'file.rxml', 'file.rjs', 'file.rant', 'file.rake', 'rakefile', 'Rakefile', 'rantfile', 'Rantfile', 'rakefile-file', 'Rakefile-file', 'Puppetfile', 'Vagrantfile'],
\ 'rust': ['file.rs'],
+ \ 'sage': ['file.sage'],
\ 'salt': ['file.sls'],
\ 'samba': ['smb.conf'],
\ 'sas': ['file.sas'],
\ 'sass': ['file.sass'],
- \ 'sather': ['file.sa'],
\ 'sbt': ['file.sbt'],
\ 'scala': ['file.scala'],
- \ 'scheme': ['file.scm', 'file.ss', 'file.sld'],
+ \ 'scheme': ['file.scm', 'file.ss', 'file.sld', 'file.stsg', 'any/local/share/supertux2/config', '.lips_repl_history'],
\ 'scilab': ['file.sci', 'file.sce'],
\ 'screen': ['.screenrc', 'screenrc'],
\ 'scss': ['file.scss'],
@@ -673,19 +685,18 @@ func s:GetFilenameChecks() abort
\ 'setserial': ['/etc/serial.conf', 'any/etc/serial.conf'],
\ 'sexplib': ['file.sexp'],
\ 'sh': ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history', '.bash-history',
- \ '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh',
+ \ '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh',
\ '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile',
\ 'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf', 'file.mdd', 'file.cygport', '.env', '.envrc', 'devscripts.conf',
\ '.devscripts', 'file.lo', 'file.la', 'file.lai'],
+ \ 'shaderslang': ['file.slang'],
\ 'sieve': ['file.siv', 'file.sieve'],
\ 'sil': ['file.sil'],
\ 'simula': ['file.sim'],
\ 'sinda': ['file.sin', 'file.s85'],
\ 'sisu': ['file.sst', 'file.ssm', 'file.ssi', 'file.-sst', 'file._sst', 'file.sst.meta', 'file.-sst.meta', 'file._sst.meta'],
\ 'skill': ['file.il', 'file.ils', 'file.cdf'],
- \ 'cdc': ['file.cdc'],
\ 'slang': ['file.sl'],
- \ 'sage': ['file.sage'],
\ 'slice': ['file.ice'],
\ 'slint': ['file.slint'],
\ 'slpconf': ['/etc/slp.conf', 'any/etc/slp.conf'],
@@ -711,7 +722,6 @@ func s:GetFilenameChecks() abort
\ 'spyce': ['file.spy', 'file.spi'],
\ 'sql': ['file.tyb', 'file.tyc', 'file.pkb', 'file.pks', '.sqlite_history'],
\ 'sqlj': ['file.sqlj'],
- \ 'prql': ['file.prql'],
\ 'sqr': ['file.sqr', 'file.sqi'],
\ 'squid': ['squid.conf'],
\ 'squirrel': ['file.nut'],
@@ -777,14 +787,13 @@ func s:GetFilenameChecks() abort
\ 'any/etc/systemd/system/file.d/.#-file',
\ 'any/etc/systemd/system/file.d/file.conf'],
\ 'systemverilog': ['file.sv', 'file.svh'],
- \ 'trace32': ['file.cmm', 'file.t32'],
+ \ 'tablegen': ['file.td'],
\ 'tags': ['tags'],
\ 'tak': ['file.tak'],
\ 'tal': ['file.tal'],
\ 'taskdata': ['pending.data', 'completed.data', 'undo.data'],
\ 'taskedit': ['file.task'],
\ 'tcl': ['file.tcl', 'file.tm', 'file.tk', 'file.itcl', 'file.itk', 'file.jacl', '.tclshrc', 'tclsh.rc', '.wishrc', '.tclsh-history', '.xsctcmdhistory', '.xsdbcmdhistory'],
- \ 'tablegen': ['file.td'],
\ 'teal': ['file.tl'],
\ 'templ': ['file.templ'],
\ 'template': ['file.tmpl'],
@@ -804,7 +813,9 @@ func s:GetFilenameChecks() abort
\ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf', 'tmux.conf.local'],
\ 'toml': ['file.toml', 'Gopkg.lock', 'Pipfile', '/home/user/.cargo/config', '.black'],
\ 'tpp': ['file.tpp'],
+ \ 'trace32': ['file.cmm', 'file.t32'],
\ 'treetop': ['file.treetop'],
+ \ 'trig': ['file.trig'],
\ 'trustees': ['trustees.conf'],
\ 'tsalt': ['file.slt'],
\ 'tsscl': ['file.tsscl'],
@@ -816,12 +827,12 @@ func s:GetFilenameChecks() abort
\ 'typescript.glimmer': ['file.gts'],
\ 'typescriptreact': ['file.tsx'],
\ 'typespec': ['file.tsp'],
- \ 'ungrammar': ['file.ungram'],
\ 'uc': ['file.uc'],
\ 'udevconf': ['/etc/udev/udev.conf', 'any/etc/udev/udev.conf'],
\ 'udevperm': ['/etc/udev/permissions.d/file.permissions', 'any/etc/udev/permissions.d/file.permissions'],
\ 'udevrules': ['/etc/udev/rules.d/file.rules', '/usr/lib/udev/rules.d/file.rules', '/lib/udev/rules.d/file.rules'],
\ 'uil': ['file.uit', 'file.uil'],
+ \ 'ungrammar': ['file.ungram'],
\ 'unison': ['file.u', 'file.uu'],
\ 'updatedb': ['/etc/updatedb.conf', 'any/etc/updatedb.conf'],
\ 'upstart': ['/usr/share/upstart/file.conf', '/usr/share/upstart/file.override', '/etc/init/file.conf', '/etc/init/file.override', '/.init/file.conf', '/.init/file.override', '/.config/upstart/file.conf', '/.config/upstart/file.override', 'any/.config/upstart/file.conf', 'any/.config/upstart/file.override', 'any/.init/file.conf', 'any/.init/file.override', 'any/etc/init/file.conf', 'any/etc/init/file.override', 'any/usr/share/upstart/file.conf', 'any/usr/share/upstart/file.override'],
@@ -874,7 +885,7 @@ func s:GetFilenameChecks() abort
\ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.fsproj', 'file.fsproj.user', 'file.vbproj', 'file.vbproj.user', 'file.ui',
\ 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old',
\ 'any/etc/xdg/menus/file.menu', 'file.atom', 'file.rss', 'file.cdxml', 'file.psc1', 'file.mpd', 'fonts.conf', 'file.xcu', 'file.xlb', 'file.xlc', 'file.xba', 'file.xpr',
- \ 'file.xpfm', 'file.spfm', 'file.bxml', 'file.mmi'],
+ \ 'file.xpfm', 'file.spfm', 'file.bxml', 'file.mmi', 'file.slnx', 'Directory.Packages.props', 'Directory.Build.targets', 'Directory.Build.props'],
\ 'xmodmap': ['anyXmodmap', 'Xmodmap', 'some-Xmodmap', 'some-xmodmap', 'some-xmodmap-file', 'xmodmap', 'xmodmap-file'],
\ 'xpm': ['file.xpm'],
\ 'xpm2': ['file.xpm2'],
@@ -884,7 +895,7 @@ func s:GetFilenameChecks() abort
\ 'xslt': ['file.xsl', 'file.xslt'],
\ 'yacc': ['file.yy', 'file.yxx', 'file.y++'],
\ 'yaml': ['file.yaml', 'file.yml', 'file.eyaml', 'any/.bundle/config', '.clangd', '.clang-format', '.clang-tidy', 'file.mplstyle', 'matplotlibrc', 'yarn.lock',
- \ '/home/user/.kube/config'],
+ \ '/home/user/.kube/config', '.condarc', 'condarc', 'pixi.lock'],
\ 'yang': ['file.yang'],
\ 'yuck': ['file.yuck'],
\ 'z8a': ['file.z8a'],
@@ -986,6 +997,7 @@ func s:GetScriptChecks() abort
\ 'expect': [['#!/path/expect']],
\ 'execline': [['#!/sbin/execlineb -S0'], ['#!/usr/bin/execlineb']],
\ 'gnuplot': [['#!/path/gnuplot']],
+ \ 'just': [['#!/path/just']],
\ 'make': [['#!/path/make']],
\ 'nix': [['#!/path/nix-shell']],
\ 'pike': [['#!/path/pike'],
@@ -1191,6 +1203,22 @@ func Test_cfg_file()
filetype off
endfunc
+func Test_cl_file()
+ filetype on
+
+ call writefile(['/*', ' * Xfile.cl', ' */', 'int f() {}'], 'Xfile.cl')
+ split Xfile.cl
+ call assert_equal('opencl', &filetype)
+ bwipe!
+
+ call writefile(['()'], 'Xfile.cl')
+ split Xfile.cl
+ call assert_equal('lisp', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_d_file()
filetype on
@@ -2273,6 +2301,43 @@ func Test_cls_file()
filetype off
endfunc
+func Test_cmd_file()
+ filetype on
+
+ call writefile(['--rom_model'], 'Xfile.cmd')
+ split Xfile.cmd
+ call assert_equal('lnk', &filetype)
+ bwipe!
+
+ call writefile(['/* comment */'], 'Xfile.cmd')
+ split Xfile.cmd
+ call assert_equal('rexx', &filetype)
+ bwipe!
+
+ call writefile(['REM comment'], 'Xfile.cmd')
+ split Xfile.cmd
+ call assert_equal('dosbatch', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
+func Test_sa_file()
+ filetype on
+
+ call writefile([';* XXX-a.sa: XXX for TI C6000 DSP *;', '.no_mdep'], 'Xfile.sa')
+ split Xfile.sa
+ call assert_equal('tiasm', &filetype)
+ bwipe!
+
+ call writefile(['-- comment'], 'Xfile.sa')
+ split Xfile.sa
+ call assert_equal('sather', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_sig_file()
filetype on
@@ -2737,6 +2802,24 @@ func Test_make_file()
filetype off
endfunc
+func Test_map_file()
+ filetype on
+
+ " TI linker map file
+ call writefile(['******************************************************************************', ' TMS320C6x Linker Unix v7.4.24 ', '******************************************************************************'], 'Xfile.map', 'D')
+ split Xfile.map
+ call assert_equal('lnkmap', &filetype)
+ bwipe!
+
+ " UMN mapserver config file
+ call writefile(['MAP', 'NAME "local-demo"', 'END'], 'Xfile.map', 'D')
+ split Xfile.map
+ call assert_equal('map', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_org_file()
filetype on
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index 327ea98e1c..738a417b86 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -2390,6 +2390,85 @@ func Test_getchar()
call assert_equal("\<M-F2>", getchar(0))
call assert_equal(0, getchar(0))
+ call feedkeys("\<Tab>", '')
+ call assert_equal(char2nr("\<Tab>"), getchar())
+ call feedkeys("\<Tab>", '')
+ call assert_equal(char2nr("\<Tab>"), getchar(-1))
+ call feedkeys("\<Tab>", '')
+ call assert_equal(char2nr("\<Tab>"), getchar(-1, {}))
+ call feedkeys("\<Tab>", '')
+ call assert_equal(char2nr("\<Tab>"), getchar(-1, #{number: v:true}))
+ call assert_equal(0, getchar(0))
+ call assert_equal(0, getchar(1))
+ call assert_equal(0, getchar(0, #{number: v:true}))
+ call assert_equal(0, getchar(1, #{number: v:true}))
+
+ call feedkeys("\<Tab>", '')
+ call assert_equal("\<Tab>", getcharstr())
+ call feedkeys("\<Tab>", '')
+ call assert_equal("\<Tab>", getcharstr(-1))
+ call feedkeys("\<Tab>", '')
+ call assert_equal("\<Tab>", getcharstr(-1, {}))
+ call feedkeys("\<Tab>", '')
+ call assert_equal("\<Tab>", getchar(-1, #{number: v:false}))
+ call assert_equal('', getcharstr(0))
+ call assert_equal('', getcharstr(1))
+ call assert_equal('', getchar(0, #{number: v:false}))
+ call assert_equal('', getchar(1, #{number: v:false}))
+
+ " Nvim: <M-x> is never simplified
+ " for key in ["C-I", "C-X", "M-x"]
+ for key in ["C-I", "C-X"]
+ let lines =<< eval trim END
+ call feedkeys("\<*{key}>", '')
+ call assert_equal(char2nr("\<{key}>"), getchar())
+ call feedkeys("\<*{key}>", '')
+ call assert_equal(char2nr("\<{key}>"), getchar(-1))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal(char2nr("\<{key}>"), getchar(-1, {{}}))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal(char2nr("\<{key}>"), getchar(-1, {{'number': 1}}))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal(char2nr("\<{key}>"), getchar(-1, {{'simplify': 1}}))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<*{key}>", getchar(-1, {{'simplify': v:false}}))
+ call assert_equal(0, getchar(0))
+ call assert_equal(0, getchar(1))
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ let lines =<< eval trim END
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<{key}>", getcharstr())
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<{key}>", getcharstr(-1))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<{key}>", getcharstr(-1, {{}}))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<{key}>", getchar(-1, {{'number': 0}}))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<{key}>", getcharstr(-1, {{'simplify': 1}}))
+ call feedkeys("\<*{key}>", '')
+ call assert_equal("\<*{key}>", getcharstr(-1, {{'simplify': v:false}}))
+ call assert_equal('', getcharstr(0))
+ call assert_equal('', getcharstr(1))
+ END
+ call CheckLegacyAndVim9Success(lines)
+ endfor
+
+ call assert_fails('call getchar(1, 1)', 'E1206:')
+ call assert_fails('call getcharstr(1, 1)', 'E1206:')
+ call assert_fails('call getchar(1, #{cursor: "foo"})', 'E475:')
+ call assert_fails('call getcharstr(1, #{cursor: "foo"})', 'E475:')
+ call assert_fails('call getchar(1, #{cursor: 0z})', 'E976:')
+ call assert_fails('call getcharstr(1, #{cursor: 0z})', 'E976:')
+ call assert_fails('call getchar(1, #{simplify: 0z})', 'E974:')
+ call assert_fails('call getcharstr(1, #{simplify: 0z})', 'E974:')
+ call assert_fails('call getchar(1, #{number: []})', 'E745:')
+ call assert_fails('call getchar(1, #{number: {}})', 'E728:')
+ call assert_fails('call getcharstr(1, #{number: v:true})', 'E475:')
+ call assert_fails('call getcharstr(1, #{number: v:false})', 'E475:')
+
call setline(1, 'xxxx')
call Ntest_setmouse(1, 3)
let v:mouse_win = 9
@@ -2405,10 +2484,59 @@ func Test_getchar()
enew!
endfunc
+func Test_getchar_cursor_position()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ call setline(1, ['foobar', 'foobar', 'foobar'])
+ call cursor(3, 6)
+ nnoremap <F1> <Cmd>echo 1234<Bar>call getchar()<CR>
+ nnoremap <F2> <Cmd>call getchar()<CR>
+ nnoremap <F3> <Cmd>call getchar(-1, {})<CR>
+ nnoremap <F4> <Cmd>call getchar(-1, #{cursor: 'msg'})<CR>
+ nnoremap <F5> <Cmd>call getchar(-1, #{cursor: 'keep'})<CR>
+ nnoremap <F6> <Cmd>call getchar(-1, #{cursor: 'hide'})<CR>
+ END
+ call writefile(lines, 'XgetcharCursorPos', 'D')
+ let buf = RunVimInTerminal('-S XgetcharCursorPos', {'rows': 6})
+ call WaitForAssert({-> assert_equal([3, 6], term_getcursor(buf)[0:1])})
+
+ call term_sendkeys(buf, "\<F1>")
+ call WaitForAssert({-> assert_equal([6, 5], term_getcursor(buf)[0:1])})
+ call assert_true(term_getcursor(buf)[2].visible)
+ call term_sendkeys(buf, 'a')
+ call WaitForAssert({-> assert_equal([3, 6], term_getcursor(buf)[0:1])})
+ call assert_true(term_getcursor(buf)[2].visible)
+
+ for key in ["\<F2>", "\<F3>", "\<F4>"]
+ call term_sendkeys(buf, key)
+ call WaitForAssert({-> assert_equal([6, 1], term_getcursor(buf)[0:1])})
+ call assert_true(term_getcursor(buf)[2].visible)
+ call term_sendkeys(buf, 'a')
+ call WaitForAssert({-> assert_equal([3, 6], term_getcursor(buf)[0:1])})
+ call assert_true(term_getcursor(buf)[2].visible)
+ endfor
+
+ call term_sendkeys(buf, "\<F5>")
+ call TermWait(buf, 50)
+ call assert_equal([3, 6], term_getcursor(buf)[0:1])
+ call assert_true(term_getcursor(buf)[2].visible)
+ call term_sendkeys(buf, 'a')
+ call TermWait(buf, 50)
+ call assert_equal([3, 6], term_getcursor(buf)[0:1])
+ call assert_true(term_getcursor(buf)[2].visible)
+
+ call term_sendkeys(buf, "\<F6>")
+ call WaitForAssert({-> assert_false(term_getcursor(buf)[2].visible)})
+ call term_sendkeys(buf, 'a')
+ call WaitForAssert({-> assert_true(term_getcursor(buf)[2].visible)})
+ call assert_equal([3, 6], term_getcursor(buf)[0:1])
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_libcall_libcallnr()
- if !has('libcall')
- return
- endif
+ CheckFeature libcall
if has('win32')
let libc = 'msvcrt.dll'
@@ -2672,7 +2800,9 @@ endfunc
func Test_call()
call assert_equal(3, call('len', [123]))
call assert_equal(3, 'len'->call([123]))
- call assert_fails("call call('len', 123)", 'E714:')
+ call assert_equal(4, call({ x -> len(x) }, ['xxxx']))
+ call assert_equal(2, call(function('len'), ['xx']))
+ call assert_fails("call call('len', 123)", 'E1211:')
call assert_equal(0, call('', []))
call assert_equal(0, call('len', v:_null_list))
diff --git a/test/old/testdir/test_highlight.vim b/test/old/testdir/test_highlight.vim
index 0a64c63d30..56c7a9656f 100644
--- a/test/old/testdir/test_highlight.vim
+++ b/test/old/testdir/test_highlight.vim
@@ -785,8 +785,8 @@ func Test_1_highlight_Normalgroup_exists()
if !has('gui_running')
call assert_match('hi Normal\s*clear', hlNormal)
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
- " expect is DEFAULT_FONT of gui_gtk_x11.c
- call assert_match('hi Normal\s*font=Monospace 10', hlNormal)
+ " expect is DEFAULT_FONT of gui_gtk_x11.c (any size)
+ call assert_match('hi Normal\s*font=Monospace\>', hlNormal)
elseif has('gui_motif')
" expect is DEFAULT_FONT of gui_x11.c
call assert_match('hi Normal\s*font=7x13', hlNormal)
diff --git a/test/old/testdir/test_indent.vim b/test/old/testdir/test_indent.vim
index dcacc11663..630beed810 100644
--- a/test/old/testdir/test_indent.vim
+++ b/test/old/testdir/test_indent.vim
@@ -1,5 +1,8 @@
" Test for various indent options
+source shared.vim
+source check.vim
+
func Test_preserveindent()
new
" Test for autoindent copying indent from the previous line
@@ -276,4 +279,77 @@ func Test_formatting_keeps_first_line_indent()
bwipe!
endfunc
+" Test for indenting with large amount, causes overflow
+func Test_indent_overflow_count()
+ throw 'skipped: TODO: '
+ new
+ setl sw=8
+ call setline(1, "abc")
+ norm! V2147483647>
+ " indents by INT_MAX
+ call assert_equal(2147483647, indent(1))
+ close!
+endfunc
+
+func Test_indent_overflow_count2()
+ throw 'skipped: Nvim does not support 64-bit number options'
+ new
+ " this only works, when long is 64bits
+ try
+ setl sw=0x180000000
+ catch /^Vim\%((\a\+)\)\=:E487:/
+ throw 'Skipped: value negative on this platform'
+ endtry
+ call setline(1, "\tabc")
+ norm! <<
+ call assert_equal(0, indent(1))
+ close!
+endfunc
+
+" Test that mouse shape is restored to Normal mode after using "gq" when
+" 'indentexpr' executes :normal.
+func Test_mouse_shape_indent_norm_with_gq()
+ CheckFeature mouseshape
+ CheckCanRunGui
+
+ let lines =<< trim END
+ func Indent()
+ exe "normal! \<Ignore>"
+ return 0
+ endfunc
+
+ setlocal indentexpr=Indent()
+ END
+ call writefile(lines, 'Xindentexpr.vim', 'D')
+
+ let lines =<< trim END
+ vim9script
+ var mouse_shapes = []
+
+ setline(1, [repeat('a', 80), repeat('b', 80)])
+
+ feedkeys('ggVG')
+ timer_start(50, (_) => {
+ mouse_shapes += [getmouseshape()]
+ timer_start(50, (_) => {
+ feedkeys('gq')
+ timer_start(50, (_) => {
+ mouse_shapes += [getmouseshape()]
+ timer_start(50, (_) => {
+ writefile(mouse_shapes, 'Xmouseshapes')
+ quit!
+ })
+ })
+ })
+ })
+ END
+ call writefile(lines, 'Xmouseshape.vim', 'D')
+
+ call RunVim([], [], "-g -S Xindentexpr.vim -S Xmouseshape.vim")
+ call WaitForAssert({-> assert_equal(['rightup-arrow', 'arrow'],
+ \ readfile('Xmouseshapes'))}, 300)
+
+ call delete('Xmouseshapes')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
index c02aa1db62..2fb1715634 100644
--- a/test/old/testdir/test_ins_complete.vim
+++ b/test/old/testdir/test_ins_complete.vim
@@ -253,6 +253,91 @@ func Test_CompleteDoneNone()
au! CompleteDone
endfunc
+func Test_CompleteDone_vevent_keys()
+ func OnDone()
+ let g:complete_word = get(v:event, 'complete_word', v:null)
+ let g:complete_type = get(v:event, 'complete_type', v:null)
+ endfunction
+
+ autocmd CompleteDone * :call OnDone()
+
+ func CompleteFunc(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return [#{word: "foo"}, #{word: "bar"}]
+ endfunc
+ set omnifunc=CompleteFunc
+ set completefunc=CompleteFunc
+ set completeopt+=menuone
+
+ new
+ call feedkeys("A\<C-X>\<C-O>\<Esc>", 'tx')
+ call assert_equal('', g:complete_word)
+ call assert_equal('omni', g:complete_type)
+
+ call feedkeys("S\<C-X>\<C-O>\<C-Y>\<Esc>", 'tx')
+ call assert_equal('foo', g:complete_word)
+ call assert_equal('omni', g:complete_type)
+
+ call feedkeys("S\<C-X>\<C-O>\<C-N>\<C-Y>\<Esc>0", 'tx')
+ call assert_equal('bar', g:complete_word)
+ call assert_equal('omni', g:complete_type)
+
+ call feedkeys("Shello vim visual v\<C-X>\<C-N>\<ESC>", 'tx')
+ call assert_equal('', g:complete_word)
+ call assert_equal('keyword', g:complete_type)
+
+ call feedkeys("Shello vim visual v\<C-X>\<C-N>\<C-Y>", 'tx')
+ call assert_equal('vim', g:complete_word)
+ call assert_equal('keyword', g:complete_type)
+
+ call feedkeys("Shello vim visual v\<C-X>\<C-N>\<C-Y>", 'tx')
+ call assert_equal('vim', g:complete_word)
+ call assert_equal('keyword', g:complete_type)
+
+ call feedkeys("Shello vim\<CR>completion test\<CR>\<C-X>\<C-l>\<C-Y>", 'tx')
+ call assert_equal('completion test', g:complete_word)
+ call assert_equal('whole_line', g:complete_type)
+
+ call feedkeys("S\<C-X>\<C-U>\<C-Y>", 'tx')
+ call assert_equal('foo', g:complete_word)
+ call assert_equal('function', g:complete_type)
+
+ inoremap <buffer> <f3> <cmd>call complete(1, ["red", "blue"])<cr>
+ call feedkeys("S\<f3>\<C-Y>", 'tx')
+ call assert_equal('red', g:complete_word)
+ call assert_equal('eval', g:complete_type)
+
+ call feedkeys("S\<C-X>\<C-V>\<C-Y>", 'tx')
+ call assert_equal('!', g:complete_word)
+ call assert_equal('cmdline', g:complete_type)
+
+ call writefile([''], 'foo_test', 'D')
+ call feedkeys("Sfoo\<C-X>\<C-F>\<C-Y>\<Esc>", 'tx')
+ call assert_equal('foo_test', g:complete_word)
+ call assert_equal('files', g:complete_type)
+
+ call writefile(['hello help'], 'test_case.txt', 'D')
+ set dictionary=test_case.txt
+ call feedkeys("ggdGSh\<C-X>\<C-K>\<C-Y>\<Esc>", 'tx')
+ call assert_equal('hello', g:complete_word)
+ call assert_equal('dictionary', g:complete_type)
+
+ set spell spelllang=en_us
+ call feedkeys("STheatre\<C-X>s\<C-Y>\<Esc>", 'tx')
+ call assert_equal('Theater', g:complete_word)
+ call assert_equal('spell', g:complete_type)
+
+ bwipe!
+ set completeopt& omnifunc& completefunc& spell& spelllang& dictionary&
+ autocmd! CompleteDone
+ delfunc OnDone
+ delfunc CompleteFunc
+ unlet g:complete_word
+ unlet g:complete_type
+endfunc
+
func Test_CompleteDoneDict()
au CompleteDonePre * :call <SID>CompleteDone_CheckCompletedItemDict(1)
au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict(0)
@@ -1509,7 +1594,7 @@ func Test_complete_item_refresh_always()
set completefunc=Tcomplete
exe "normal! iup\<C-X>\<C-U>\<BS>\<BS>\<BS>\<BS>\<BS>"
call assert_equal('up', getline(1))
- call assert_equal(2, g:CallCount)
+ call assert_equal(6, g:CallCount)
set completeopt&
set completefunc&
bw!
@@ -2693,7 +2778,7 @@ func Test_complete_fuzzy_match()
if a:findstart
return col(".")
endif
- return [#{word: "foo"}, #{word: "foobar"}, #{word: "fooBaz"}, #{word: "foobala"}]
+ return [#{word: "foo"}, #{word: "foobar"}, #{word: "fooBaz"}, #{word: "foobala"}, #{word: "你好吗"}, #{word: "我好"}]
endfunc
new
@@ -2752,6 +2837,26 @@ func Test_complete_fuzzy_match()
call feedkeys("STe\<C-X>\<C-N>x\<CR>\<Esc>0", 'tx!')
call assert_equal('Tex', getline('.'))
+ " test case for nosort option
+ set cot=menuone,menu,noinsert,fuzzy,nosort
+ " "fooBaz" should have a higher score when the leader is "fb".
+ " With "nosort", "foobar" should still be shown first in the popup menu.
+ call feedkeys("S\<C-x>\<C-o>fb", 'tx')
+ call assert_equal('foobar', g:word)
+ call feedkeys("S\<C-x>\<C-o>好", 'tx')
+ call assert_equal("你好吗", g:word)
+
+ set cot+=noselect
+ call feedkeys("S\<C-x>\<C-o>好", 'tx')
+ call assert_equal(v:null, g:word)
+ call feedkeys("S\<C-x>\<C-o>好\<C-N>", 'tx')
+ call assert_equal('你好吗', g:word)
+
+ " "nosort" shouldn't enable fuzzy filtering when "fuzzy" isn't present.
+ set cot=menuone,noinsert,nosort
+ call feedkeys("S\<C-x>\<C-o>fooB\<C-Y>", 'tx')
+ call assert_equal('fooBaz', getline('.'))
+
" clean up
set omnifunc=
bw!
@@ -2785,4 +2890,203 @@ func Test_complete_fuzzy_match_tie()
set completeopt&
endfunc
+func Test_complete_info_matches()
+ let g:what = ['matches']
+ func ShownInfo()
+ let g:compl_info = complete_info(g:what)
+ return ''
+ endfunc
+ set completeopt+=noinsert
+
+ new
+ call setline(1, ['aaa', 'aab', 'aba', 'abb'])
+ inoremap <buffer><F5> <C-R>=ShownInfo()<CR>
+
+ call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal([
+ \ {'word': 'aaa', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'aab', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'aba', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'abb', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
+ \], g:compl_info['matches'])
+
+ call feedkeys("Goa\<C-X>\<C-N>b\<F5>\<Esc>dd", 'tx')
+ call assert_equal([
+ \ {'word': 'aba', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'abb', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
+ \], g:compl_info['matches'])
+
+ " items and matches both in what
+ let g:what = ['items', 'matches']
+ call feedkeys("Goa\<C-X>\<C-N>b\<F5>\<Esc>dd", 'tx')
+ call assert_equal([
+ \ {'word': 'aaa', 'menu': '', 'user_data': '', 'match': v:false, 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'aab', 'menu': '', 'user_data': '', 'match': v:false, 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'aba', 'menu': '', 'user_data': '', 'match': v:true, 'info': '', 'kind': '', 'abbr': ''},
+ \ {'word': 'abb', 'menu': '', 'user_data': '', 'match': v:true, 'info': '', 'kind': '', 'abbr': ''},
+ \], g:compl_info['items'])
+ call assert_false(has_key(g:compl_info, 'matches'))
+
+ bw!
+ unlet g:what
+ delfunc ShownInfo
+ set cot&
+endfunc
+
+func Test_complete_info_completed()
+ func ShownInfo()
+ let g:compl_info = complete_info(['completed'])
+ return ''
+ endfunc
+ set completeopt+=noinsert
+
+ new
+ call setline(1, ['aaa', 'aab', 'aba', 'abb'])
+ inoremap <buffer><F5> <C-R>=ShownInfo()<CR>
+
+ call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({'word': 'aaa', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, g:compl_info['completed'])
+
+ call feedkeys("Go\<C-X>\<C-N>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({'word': 'aab', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, g:compl_info['completed'])
+
+ call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({'word': 'abb', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, g:compl_info['completed'])
+
+ set completeopt+=noselect
+ call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>dd", 'tx')
+ call assert_equal({}, g:compl_info)
+
+ bw!
+ delfunc ShownInfo
+ set cot&
+endfunc
+
+function Test_completeopt_preinsert()
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return [#{word: "fobar"}, #{word: "foobar"}, #{word: "你的"}, #{word: "你好世界"}]
+ endfunc
+ set omnifunc=Omni_test
+ set completeopt=menu,menuone,preinsert
+
+ new
+ call feedkeys("S\<C-X>\<C-O>f", 'tx')
+ call assert_equal("fobar", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("S\<C-X>\<C-O>foo", 'tx')
+ call assert_equal("foobar", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("S\<C-X>\<C-O>foo\<BS>\<BS>\<BS>", 'tx')
+ call assert_equal("", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ " delete a character and input new leader
+ call feedkeys("S\<C-X>\<C-O>foo\<BS>b", 'tx')
+ call assert_equal("fobar", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ " delete preinsert when prepare completion
+ call feedkeys("S\<C-X>\<C-O>f\<Space>", 'tx')
+ call assert_equal("f ", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("S\<C-X>\<C-O>你", 'tx')
+ call assert_equal("你的", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("S\<C-X>\<C-O>你好", 'tx')
+ call assert_equal("你好世界", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("Shello wo\<Left>\<Left>\<Left>\<C-X>\<C-O>f", 'tx')
+ call assert_equal("hello fobar wo", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("Shello wo\<Left>\<Left>\<Left>\<C-X>\<C-O>f\<BS>", 'tx')
+ call assert_equal("hello wo", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("Shello wo\<Left>\<Left>\<Left>\<C-X>\<C-O>foo", 'tx')
+ call assert_equal("hello foobar wo", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ call feedkeys("Shello wo\<Left>\<Left>\<Left>\<C-X>\<C-O>foo\<BS>b", 'tx')
+ call assert_equal("hello fobar wo", getline('.'))
+ call feedkeys("\<C-E>\<ESC>", 'tx')
+
+ " confirm
+ call feedkeys("S\<C-X>\<C-O>f\<C-Y>", 'tx')
+ call assert_equal("fobar", getline('.'))
+ call assert_equal(5, col('.'))
+
+ " cancel
+ call feedkeys("S\<C-X>\<C-O>fo\<C-E>", 'tx')
+ call assert_equal("fo", getline('.'))
+ call assert_equal(2, col('.'))
+
+ call feedkeys("S hello hero\<CR>h\<C-X>\<C-N>", 'tx')
+ call assert_equal("hello", getline('.'))
+ call assert_equal(1, col('.'))
+
+ call feedkeys("Sh\<C-X>\<C-N>\<C-Y>", 'tx')
+ call assert_equal("hello", getline('.'))
+ call assert_equal(5, col('.'))
+
+ " delete preinsert part
+ call feedkeys("S\<C-X>\<C-O>fo ", 'tx')
+ call assert_equal("fo ", getline('.'))
+ call assert_equal(3, col('.'))
+
+ call feedkeys("She\<C-X>\<C-N>\<C-U>", 'tx')
+ call assert_equal("", getline('.'))
+ call assert_equal(1, col('.'))
+
+ call feedkeys("She\<C-X>\<C-N>\<C-W>", 'tx')
+ call assert_equal("", getline('.'))
+ call assert_equal(1, col('.'))
+
+ " whole line
+ call feedkeys("Shello hero\<CR>\<C-X>\<C-L>", 'tx')
+ call assert_equal("hello hero", getline('.'))
+ call assert_equal(1, col('.'))
+
+ call feedkeys("Shello hero\<CR>he\<C-X>\<C-L>", 'tx')
+ call assert_equal("hello hero", getline('.'))
+ call assert_equal(2, col('.'))
+
+ call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>er", 'tx')
+ call assert_equal("hero", getline('.'))
+ call assert_equal(3, col('.'))
+
+ " can not work with fuzzy
+ set cot+=fuzzy
+ call feedkeys("S\<C-X>\<C-O>", 'tx')
+ call assert_equal("fobar", getline('.'))
+ call assert_equal(5, col('.'))
+
+ " test for fuzzy and noinsert
+ set cot+=noinsert
+ call feedkeys("S\<C-X>\<C-O>fb", 'tx')
+ call assert_equal("fb", getline('.'))
+ call assert_equal(2, col('.'))
+
+ call feedkeys("S\<C-X>\<C-O>你", 'tx')
+ call assert_equal("你", getline('.'))
+ call assert_equal(1, col('.'))
+
+ call feedkeys("S\<C-X>\<C-O>fb\<C-Y>", 'tx')
+ call assert_equal("fobar", getline('.'))
+ call assert_equal(5, col('.'))
+
+ bw!
+ set cot&
+ set omnifunc&
+ delfunc Omni_test
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim
index 44852c1d38..22a3a35f87 100644
--- a/test/old/testdir/test_let.vim
+++ b/test/old/testdir/test_let.vim
@@ -436,6 +436,24 @@ func Test_let_heredoc_fails()
call assert_report('Caught exception: ' .. v:exception)
endtry
+ try
+ let v =<< trim trimm
+ trimm
+ call assert_report('No exception thrown')
+ catch /E221:/
+ catch
+ call assert_report('Caught exception: ' .. v:exception)
+ endtry
+
+ try
+ let v =<< trim trim evall
+ evall
+ call assert_report('No exception thrown')
+ catch /E221:/
+ catch
+ call assert_report('Caught exception: ' .. v:exception)
+ endtry
+
let text =<< trim END
func WrongSyntax()
let v =<< that there
diff --git a/test/old/testdir/test_matchfuzzy.vim b/test/old/testdir/test_matchfuzzy.vim
index 90f3366b23..0c982c19f1 100644
--- a/test/old/testdir/test_matchfuzzy.vim
+++ b/test/old/testdir/test_matchfuzzy.vim
@@ -23,6 +23,8 @@ func Test_matchfuzzy()
call assert_equal(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], matchfuzzy(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'aa'))
call assert_equal(256, matchfuzzy([repeat('a', 256)], repeat('a', 256))[0]->len())
call assert_equal([], matchfuzzy([repeat('a', 300)], repeat('a', 257)))
+ " full match has highest score
+ call assert_equal(['Cursor', 'lCursor'], matchfuzzy(["hello", "lCursor", "Cursor"], "Cursor"))
" matches with same score should not be reordered
let l = ['abc1', 'abc2', 'abc3']
call assert_equal(l, l->matchfuzzy('abc'))
@@ -98,15 +100,15 @@ endfunc
" Test for the matchfuzzypos() function
func Test_matchfuzzypos()
- call assert_equal([['curl', 'world'], [[2,3], [2,3]], [128, 127]], matchfuzzypos(['world', 'curl'], 'rl'))
- call assert_equal([['curl', 'world'], [[2,3], [2,3]], [128, 127]], matchfuzzypos(['world', 'one', 'curl'], 'rl'))
+ call assert_equal([['curl', 'world'], [[2,3], [2,3]], [178, 177]], matchfuzzypos(['world', 'curl'], 'rl'))
+ call assert_equal([['curl', 'world'], [[2,3], [2,3]], [178, 177]], matchfuzzypos(['world', 'one', 'curl'], 'rl'))
call assert_equal([['hello', 'hello world hello world'],
- \ [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]], [275, 257]],
+ \ [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]], [500, 382]],
\ matchfuzzypos(['hello world hello world', 'hello', 'world'], 'hello'))
- call assert_equal([['aaaaaaa'], [[0, 1, 2]], [191]], matchfuzzypos(['aaaaaaa'], 'aaa'))
- call assert_equal([['a b'], [[0, 3]], [219]], matchfuzzypos(['a b'], 'a b'))
- call assert_equal([['a b'], [[0, 3]], [219]], matchfuzzypos(['a b'], 'a b'))
- call assert_equal([['a b'], [[0]], [112]], matchfuzzypos(['a b'], ' a '))
+ call assert_equal([['aaaaaaa'], [[0, 1, 2]], [266]], matchfuzzypos(['aaaaaaa'], 'aaa'))
+ call assert_equal([['a b'], [[0, 3]], [269]], matchfuzzypos(['a b'], 'a b'))
+ call assert_equal([['a b'], [[0, 3]], [269]], matchfuzzypos(['a b'], 'a b'))
+ call assert_equal([['a b'], [[0]], [137]], matchfuzzypos(['a b'], ' a '))
call assert_equal([[], [], []], matchfuzzypos(['a b'], ' '))
call assert_equal([[], [], []], matchfuzzypos(['world', 'curl'], 'ab'))
let x = matchfuzzypos([repeat('a', 256)], repeat('a', 256))
@@ -115,33 +117,33 @@ func Test_matchfuzzypos()
call assert_equal([[], [], []], matchfuzzypos([], 'abc'))
" match in a long string
- call assert_equal([[repeat('x', 300) .. 'abc'], [[300, 301, 302]], [-135]],
+ call assert_equal([[repeat('x', 300) .. 'abc'], [[300, 301, 302]], [-60]],
\ matchfuzzypos([repeat('x', 300) .. 'abc'], 'abc'))
" preference for camel case match
- call assert_equal([['xabcxxaBc'], [[6, 7, 8]], [189]], matchfuzzypos(['xabcxxaBc'], 'abc'))
+ call assert_equal([['xabcxxaBc'], [[6, 7, 8]], [269]], matchfuzzypos(['xabcxxaBc'], 'abc'))
" preference for match after a separator (_ or space)
- call assert_equal([['xabx_ab'], [[5, 6]], [145]], matchfuzzypos(['xabx_ab'], 'ab'))
+ call assert_equal([['xabx_ab'], [[5, 6]], [195]], matchfuzzypos(['xabx_ab'], 'ab'))
" preference for leading letter match
- call assert_equal([['abcxabc'], [[0, 1]], [150]], matchfuzzypos(['abcxabc'], 'ab'))
+ call assert_equal([['abcxabc'], [[0, 1]], [200]], matchfuzzypos(['abcxabc'], 'ab'))
" preference for sequential match
- call assert_equal([['aobncedone'], [[7, 8, 9]], [158]], matchfuzzypos(['aobncedone'], 'one'))
+ call assert_equal([['aobncedone'], [[7, 8, 9]], [233]], matchfuzzypos(['aobncedone'], 'one'))
" best recursive match
- call assert_equal([['xoone'], [[2, 3, 4]], [168]], matchfuzzypos(['xoone'], 'one'))
+ call assert_equal([['xoone'], [[2, 3, 4]], [243]], matchfuzzypos(['xoone'], 'one'))
" match multiple words (separated by space)
- call assert_equal([['foo bar baz'], [[8, 9, 10, 0, 1, 2]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo'))
+ call assert_equal([['foo bar baz'], [[8, 9, 10, 0, 1, 2]], [519]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo'))
call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('baz foo', {'matchseq': 1}))
- call assert_equal([['foo bar baz'], [[0, 1, 2, 8, 9, 10]], [369]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz'))
- call assert_equal([['foo bar baz'], [[0, 1, 2, 3, 4, 5, 10]], [326]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz', {'matchseq': 1}))
+ call assert_equal([['foo bar baz'], [[0, 1, 2, 8, 9, 10]], [519]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz'))
+ call assert_equal([['foo bar baz'], [[0, 1, 2, 3, 4, 5, 10]], [476]], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('foo baz', {'matchseq': 1}))
call assert_equal([[], [], []], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzypos('one two'))
call assert_equal([[], [], []], ['foo bar']->matchfuzzypos(" \t "))
- call assert_equal([['grace'], [[1, 2, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4]], [657]], ['grace']->matchfuzzypos('race ace grace'))
+ call assert_equal([['grace'], [[1, 2, 3, 4, 2, 3, 4, 0, 1, 2, 3, 4]], [1057]], ['grace']->matchfuzzypos('race ace grace'))
let l = [{'id' : 5, 'val' : 'crayon'}, {'id' : 6, 'val' : 'camera'}]
- call assert_equal([[{'id' : 6, 'val' : 'camera'}], [[0, 1, 2]], [192]],
+ call assert_equal([[{'id' : 6, 'val' : 'camera'}], [[0, 1, 2]], [267]],
\ matchfuzzypos(l, 'cam', {'text_cb' : {v -> v.val}}))
- call assert_equal([[{'id' : 6, 'val' : 'camera'}], [[0, 1, 2]], [192]],
+ call assert_equal([[{'id' : 6, 'val' : 'camera'}], [[0, 1, 2]], [267]],
\ matchfuzzypos(l, 'cam', {'key' : 'val'}))
call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'text_cb' : {v -> v.val}}))
call assert_equal([[], [], []], matchfuzzypos(l, 'day', {'key' : 'val'}))
@@ -159,6 +161,18 @@ func Test_matchfuzzypos()
" Nvim doesn't have null functions
" call assert_fails("let x = matchfuzzypos(l, 'foo', {'text_cb' : test_null_function()})", 'E475:')
+ " case match
+ call assert_equal([['Match', 'match'], [[0, 1], [0, 1]], [202, 177]], matchfuzzypos(['match', 'Match'], 'Ma'))
+ call assert_equal([['match', 'Match'], [[0, 1], [0, 1]], [202, 177]], matchfuzzypos(['Match', 'match'], 'ma'))
+ " CamelCase has high weight even case match
+ call assert_equal(['MyTestCase', 'mytestcase'], matchfuzzy(['mytestcase', 'MyTestCase'], 'mtc'))
+ call assert_equal(['MyTestCase', 'mytestcase'], matchfuzzy(['MyTestCase', 'mytestcase'], 'mtc'))
+ call assert_equal(['MyTest', 'Mytest', 'mytest', ],matchfuzzy(['Mytest', 'mytest', 'MyTest'], 'MyT'))
+ call assert_equal(['CamelCaseMatchIngAlg', 'camelCaseMatchingAlg', 'camelcasematchingalg'],
+ \ matchfuzzy(['CamelCaseMatchIngAlg', 'camelcasematchingalg', 'camelCaseMatchingAlg'], 'CamelCase'))
+ call assert_equal(['CamelCaseMatchIngAlg', 'camelCaseMatchingAlg', 'camelcasematchingalg'],
+ \ matchfuzzy(['CamelCaseMatchIngAlg', 'camelcasematchingalg', 'camelCaseMatchingAlg'], 'CamelcaseM'))
+
let l = [{'id' : 5, 'name' : 'foo'}, {'id' : 6, 'name' : []}, {'id' : 7}]
call assert_fails("let x = matchfuzzypos(l, 'foo', {'key' : 'name'})", 'E730:')
endfunc
@@ -209,12 +223,12 @@ func Test_matchfuzzypos_mbyte()
call assert_equal([['ンヹㄇヺヴ'], [[1, 3]], [88]], matchfuzzypos(['ンヹㄇヺヴ'], 'ヹヺ'))
" reverse the order of characters
call assert_equal([[], [], []], matchfuzzypos(['ンヹㄇヺヴ'], 'ヺヹ'))
- call assert_equal([['αβΩxxx', 'xαxβxΩx'], [[0, 1, 2], [1, 3, 5]], [222, 113]],
+ call assert_equal([['αβΩxxx', 'xαxβxΩx'], [[0, 1, 2], [1, 3, 5]], [252, 143]],
\ matchfuzzypos(['αβΩxxx', 'xαxβxΩx'], 'αβΩ'))
call assert_equal([['ππbbππ', 'πππbbbπππ', 'ππππbbbbππππ', 'πbπ'],
- \ [[0, 1], [0, 1], [0, 1], [0, 2]], [151, 148, 145, 110]],
+ \ [[0, 1], [0, 1], [0, 1], [0, 2]], [176, 173, 170, 135]],
\ matchfuzzypos(['πbπ', 'ππbbππ', 'πππbbbπππ', 'ππππbbbbππππ'], 'ππ'))
- call assert_equal([['ααααααα'], [[0, 1, 2]], [191]],
+ call assert_equal([['ααααααα'], [[0, 1, 2]], [216]],
\ matchfuzzypos(['ααααααα'], 'ααα'))
call assert_equal([[], [], []], matchfuzzypos(['ンヹㄇ', 'ŗŝţ'], 'fffifl'))
@@ -227,10 +241,10 @@ func Test_matchfuzzypos_mbyte()
call assert_equal([[], [], []], ['세 마리의 작은 돼지', '마리의', '마리의 작은', '작은 돼지']->matchfuzzypos('파란 하늘'))
" match in a long string
- call assert_equal([[repeat('ぶ', 300) .. 'ẼẼẼ'], [[300, 301, 302]], [-135]],
+ call assert_equal([[repeat('ぶ', 300) .. 'ẼẼẼ'], [[300, 301, 302]], [-110]],
\ matchfuzzypos([repeat('ぶ', 300) .. 'ẼẼẼ'], 'ẼẼẼ'))
" preference for camel case match
- call assert_equal([['xѳѵҁxxѳѴҁ'], [[6, 7, 8]], [189]], matchfuzzypos(['xѳѵҁxxѳѴҁ'], 'ѳѵҁ'))
+ call assert_equal([['xѳѵҁxxѳѴҁ'], [[6, 7, 8]], [219]], matchfuzzypos(['xѳѵҁxxѳѴҁ'], 'ѳѵҁ'))
" preference for match after a separator (_ or space)
call assert_equal([['xちだx_ちだ'], [[5, 6]], [145]], matchfuzzypos(['xちだx_ちだ'], 'ちだ'))
" preference for leading letter match
diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim
index ac5184645f..bfead20142 100644
--- a/test/old/testdir/test_messages.vim
+++ b/test/old/testdir/test_messages.vim
@@ -216,6 +216,7 @@ endfunc
" Test more-prompt (see :help more-prompt).
func Test_message_more()
CheckRunVimInTerminal
+
let buf = RunVimInTerminal('', {'rows': 6})
call term_sendkeys(buf, ":call setline(1, range(1, 100))\n")
@@ -611,4 +612,50 @@ func Test_cmdheight_zero()
tabonly
endfunc
+func Test_messagesopt_history()
+ " After setting 'messagesopt' "history" to 2 and outputting a message 4 times
+ " with :echomsg, is the number of output lines of :messages 2?
+ set messagesopt=hit-enter,history:2
+ echomsg 'foo'
+ echomsg 'bar'
+ echomsg 'baz'
+ echomsg 'foobar'
+ call assert_equal(['baz', 'foobar'], GetMessages())
+
+ " When the number of messages is 10 and 'messagesopt' "history" is changed to
+ " 5, is the number of output lines of :messages 5?
+ set messagesopt=hit-enter,history:10
+ for num in range(1, 10)
+ echomsg num
+ endfor
+ set messagesopt=hit-enter,history:5
+ call assert_equal(5, len(GetMessages()))
+
+ " Check empty list
+ set messagesopt=hit-enter,history:0
+ call assert_true(empty(GetMessages()))
+
+ set messagesopt&
+endfunc
+
+func Test_messagesopt_wait()
+ CheckRunVimInTerminal
+
+ let buf = RunVimInTerminal('', {'rows': 6, 'cols': 45})
+ call term_sendkeys(buf, ":set cmdheight=1\n")
+
+ " Check hit-enter prompt
+ call term_sendkeys(buf, ":set messagesopt=hit-enter,history:500\n")
+ call term_sendkeys(buf, ":echo 'foo' | echo 'bar' | echo 'baz'\n")
+ call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
+
+ " Check no hit-enter prompt when "wait:" is set
+ call term_sendkeys(buf, ":set messagesopt=wait:100,history:500\n")
+ call term_sendkeys(buf, ":echo 'foo' | echo 'bar' | echo 'baz'\n")
+ call WaitForAssert({-> assert_equal(' 0,0-1 All', term_getline(buf, 6))})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index c89e73bada..1d9609cbe1 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -1338,11 +1338,27 @@ func Test_scroll_in_ex_mode()
call writefile(['done'], 'Xdone')
qa!
END
- call writefile(lines, 'Xscript')
+ call writefile(lines, 'Xscript', 'D')
call assert_equal(1, RunVim([], [], '--clean -X -Z -e -s -S Xscript'))
call assert_equal(['done'], readfile('Xdone'))
- call delete('Xscript')
+ call delete('Xdone')
+endfunc
+
+func Test_scroll_and_paste_in_ex_mode()
+ throw 'Skipped: does not work when Nvim is run from :!'
+ " This used to crash because of moving cursor to line 0.
+ let lines =<< trim END
+ v/foo/vi|YY9PYQ
+ v/bar/vi|YY9PYQ
+ v/bar/exe line('.') == 1 ? "vi|Y\<C-B>9PYQ" : "vi|YQ"
+ call writefile(['done'], 'Xdone')
+ qa!
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call assert_equal(1, RunVim([], [], '-u NONE -i NONE -n -X -Z -e -s -S Xscript'))
+ call assert_equal(['done'], readfile('Xdone'))
+
call delete('Xdone')
endfunc
@@ -4303,4 +4319,5 @@ func Test_normal_go()
bwipe!
endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index b6bdb1be52..2479f0ca51 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -496,7 +496,7 @@ func Test_set_completion_string_values()
" but don't exhaustively validate their results.
call assert_equal('single', getcompletion('set ambw=', 'cmdline')[0])
call assert_match('light\|dark', getcompletion('set bg=', 'cmdline')[1])
- call assert_equal('indent', getcompletion('set backspace=', 'cmdline')[0])
+ call assert_equal('indent,eol,start', getcompletion('set backspace=', 'cmdline')[0])
call assert_equal('yes', getcompletion('set backupcopy=', 'cmdline')[1])
call assert_equal('backspace', getcompletion('set belloff=', 'cmdline')[1])
call assert_equal('min:', getcompletion('set briopt=', 'cmdline')[1])
@@ -504,7 +504,8 @@ func Test_set_completion_string_values()
call assert_equal('current', getcompletion('set browsedir=', 'cmdline')[1])
endif
call assert_equal('unload', getcompletion('set bufhidden=', 'cmdline')[1])
- call assert_equal('nowrite', getcompletion('set buftype=', 'cmdline')[1])
+ "call assert_equal('nowrite', getcompletion('set buftype=', 'cmdline')[1])
+ call assert_equal('help', getcompletion('set buftype=', 'cmdline')[1])
call assert_equal('internal', getcompletion('set casemap=', 'cmdline')[1])
if exists('+clipboard')
" call assert_match('unnamed', getcompletion('set clipboard=', 'cmdline')[1])
@@ -644,6 +645,10 @@ func Test_set_completion_string_values()
" call feedkeys(":set hl=8b i\<Left>\<Left>\<Tab>\<C-B>\"\<CR>", 'xt')
" call assert_equal("\"set hl=8bi i", @:)
+ " messagesopt
+ call assert_equal(['history:', 'hit-enter', 'wait:'],
+ \ getcompletion('set messagesopt+=', 'cmdline')->sort())
+
"
" Test flag lists
"
@@ -706,6 +711,10 @@ func Test_set_completion_string_values()
" Test empty option
set diffopt=
call assert_equal([], getcompletion('set diffopt-=', 'cmdline'))
+ " Test all possible values
+ call assert_equal(['filler', 'context:', 'iblank', 'icase', 'iwhite', 'iwhiteall', 'iwhiteeol', 'horizontal',
+ \ 'vertical', 'closeoff', 'hiddenoff', 'foldcolumn:', 'followwrap', 'internal', 'indent-heuristic', 'algorithm:', 'linematch:'],
+ \ getcompletion('set diffopt=', 'cmdline'))
set diffopt&
" Test escaping output
@@ -743,7 +752,6 @@ func Test_set_option_errors()
call assert_fails('set backupcopy=', 'E474:')
call assert_fails('set regexpengine=3', 'E474:')
call assert_fails('set history=10001', 'E474:')
- call assert_fails('set msghistory=10001', 'E474:')
call assert_fails('set numberwidth=21', 'E474:')
call assert_fails('set colorcolumn=-a', 'E474:')
call assert_fails('set colorcolumn=a', 'E474:')
@@ -757,7 +765,6 @@ func Test_set_option_errors()
endif
call assert_fails('set helpheight=-1', 'E487:')
call assert_fails('set history=-1', 'E487:')
- call assert_fails('set msghistory=-1', 'E487:')
call assert_fails('set report=-1', 'E487:')
call assert_fails('set shiftwidth=-1', 'E487:')
call assert_fails('set sidescroll=-1', 'E487:')
@@ -2252,16 +2259,57 @@ func Test_opt_default()
call assert_equal('vt', &formatoptions)
set formatoptions&vim
call assert_equal('tcq', &formatoptions)
+
+ call assert_equal('ucs-bom,utf-8,default,latin1', &fencs)
+ set fencs=latin1
+ set fencs&
+ call assert_equal('ucs-bom,utf-8,default,latin1', &fencs)
+ set fencs=latin1
+ set all&
+ call assert_equal('ucs-bom,utf-8,default,latin1', &fencs)
endfunc
" Test for the 'cmdheight' option
-func Test_cmdheight()
+func Test_opt_cmdheight()
%bw!
let ht = &lines
set cmdheight=9999
call assert_equal(1, winheight(0))
call assert_equal(ht - 1, &cmdheight)
set cmdheight&
+
+ " The status line should be taken into account.
+ set laststatus=2
+ set cmdheight=9999
+ call assert_equal(ht - 2, &cmdheight)
+ set cmdheight& laststatus=1 " Accommodate Nvim default
+
+ " The tabline should be taken into account only non-GUI.
+ set showtabline=2
+ set cmdheight=9999
+ if has('gui_running')
+ call assert_equal(ht - 1, &cmdheight)
+ else
+ call assert_equal(ht - 2, &cmdheight)
+ endif
+ set cmdheight& showtabline&
+
+ " The 'winminheight' should be taken into account.
+ set winheight=3 winminheight=3
+ split
+ set cmdheight=9999
+ call assert_equal(ht - 8, &cmdheight)
+ %bw!
+ set cmdheight& winminheight& winheight&
+
+ " Only the windows in the current tabpage are taken into account.
+ set winheight=3 winminheight=3 showtabline=0
+ split
+ tabnew
+ set cmdheight=9999
+ call assert_equal(ht - 3, &cmdheight)
+ %bw!
+ set cmdheight& winminheight& winheight& showtabline&
endfunc
" To specify a control character as an option value, '^' can be used
@@ -2476,6 +2524,7 @@ func Test_string_option_revert_on_failure()
\ ['lispoptions', 'expr:1', 'a123'],
\ ['listchars', 'tab:->', 'tab:'],
\ ['matchpairs', '<:>', '<:'],
+ \ ['messagesopt', 'hit-enter,history:100', 'a123'],
\ ['mkspellmem', '100000,1000,100', '100000'],
\ ['mouse', 'nvi', 'z'],
\ ['mousemodel', 'extend', 'a123'],
diff --git a/test/old/testdir/test_perl.vim b/test/old/testdir/test_perl.vim
index c08a042dae..2d7f8fdc10 100644
--- a/test/old/testdir/test_perl.vim
+++ b/test/old/testdir/test_perl.vim
@@ -316,7 +316,10 @@ VIM::DoCommand('let s ..= "B"')
perl << trim eof
VIM::DoCommand('let s ..= "E"')
eof
- call assert_equal('ABCDE', s)
+ perl << trimm
+VIM::DoCommand('let s ..= "F"')
+trimm
+ call assert_equal('ABCDEF', s)
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index 601ba6c688..e4abf978ab 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -748,17 +748,11 @@ func Test_popup_and_preview_autocommand()
bw!
endfunc
-func Test_popup_and_previewwindow_dump()
+func s:run_popup_and_previewwindow_dump(lines, dumpfile)
CheckScreendump
CheckFeature quickfix
- let lines =<< trim END
- set previewheight=9
- silent! pedit
- call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
- exec "norm! G\<C-E>\<C-E>"
- END
- call writefile(lines, 'Xscript')
+ call writefile(a:lines, 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', {})
" wait for the script to finish
@@ -768,11 +762,30 @@ func Test_popup_and_previewwindow_dump()
call term_sendkeys(buf, "o")
call TermWait(buf, 50)
call term_sendkeys(buf, "\<C-X>\<C-N>")
- call VerifyScreenDump(buf, 'Test_popup_and_previewwindow_01', {})
+ call VerifyScreenDump(buf, a:dumpfile, {})
call term_sendkeys(buf, "\<Esc>u")
call StopVimInTerminal(buf)
- call delete('Xscript')
+endfunc
+
+func Test_popup_and_previewwindow_dump_pedit()
+ let lines =<< trim END
+ set previewheight=9
+ silent! pedit
+ call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
+ exec "norm! G\<C-E>\<C-E>"
+ END
+ call s:run_popup_and_previewwindow_dump(lines, 'Test_popup_and_previewwindow_pedit')
+endfunc
+
+func Test_popup_and_previewwindow_dump_pbuffer()
+ let lines =<< trim END
+ set previewheight=9
+ silent! pbuffer
+ call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
+ exec "norm! G\<C-E>\<C-E>\<C-E>"
+ END
+ call s:run_popup_and_previewwindow_dump(lines, 'Test_popup_and_previewwindow_pbuffer')
endfunc
func Test_balloon_split()
@@ -1506,6 +1519,39 @@ func Test_pum_highlights_match()
call StopVimInTerminal(buf)
endfunc
+func Test_pum_highlights_match_with_abbr()
+ CheckScreendump
+ let lines =<< trim END
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return {
+ \ 'words': [
+ \ { 'word': 'foobar', 'abbr': "foobar\t\t!" },
+ \ { 'word': 'foobaz', 'abbr': "foobaz\t\t!" },
+ \]}
+ endfunc
+
+ set omnifunc=Omni_test
+ set completeopt=menuone,noinsert
+ hi PmenuMatchSel ctermfg=6 ctermbg=7
+ hi PmenuMatch ctermfg=4 ctermbg=225
+ END
+ call writefile(lines, 'Xscript', 'D')
+ let buf = RunVimInTerminal('-S Xscript', {})
+ call TermWait(buf)
+ call term_sendkeys(buf, "i\<C-X>\<C-O>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "foo")
+ call VerifyScreenDump(buf, 'Test_pum_highlights_19', {})
+
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+ call TermWait(buf)
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_pum_user_abbr_hlgroup()
CheckScreendump
let lines =<< trim END
@@ -1675,4 +1721,168 @@ func Test_pum_completeitemalign()
call StopVimInTerminal(buf)
endfunc
+func Test_pum_keep_select()
+ CheckScreendump
+ let lines =<< trim END
+ set completeopt=menu,menuone,noinsert
+ END
+ call writefile(lines, 'Xscript', 'D')
+ let buf = RunVimInTerminal('-S Xscript', {})
+ call TermWait(buf)
+
+ call term_sendkeys(buf, "ggSFab\<CR>Five\<CR>find\<CR>film\<CR>\<C-X>\<C-P>")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_pum_keep_select_01', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+ call TermWait(buf, 50)
+
+ call term_sendkeys(buf, "S\<C-X>\<C-P>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "F")
+ call VerifyScreenDump(buf, 'Test_pum_keep_select_02', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
+ call TermWait(buf, 50)
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_pum_matchins_highlight()
+ CheckScreendump
+ let lines =<< trim END
+ let g:change = 0
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ if g:change == 0
+ return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
+ endif
+ return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}]
+ endfunc
+ set omnifunc=Omni_test
+ hi ComplMatchIns ctermfg=red
+ END
+ call writefile(lines, 'Xscript', 'D')
+ let buf = RunVimInTerminal('-S Xscript', {})
+
+ call TermWait(buf)
+ call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_01', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
+ call TermWait(buf)
+ call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_02', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
+ call TermWait(buf)
+ call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-N>\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_03', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
+ " restore after accept
+ call TermWait(buf)
+ call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_04', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ " restore after cancel completion
+ call TermWait(buf)
+ call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<Space>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_05', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ " text after the inserted text shouldn't be highlighted
+ call TermWait(buf)
+ call term_sendkeys(buf, "0ea \<C-X>\<C-O>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_07', {})
+ call term_sendkeys(buf, "\<C-P>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_08', {})
+ call term_sendkeys(buf, "\<C-P>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_09', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_10', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call term_sendkeys(buf, ":let g:change=1\<CR>S\<C-X>\<C-O>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_11', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_pum_matchins_highlight_combine()
+ CheckScreendump
+ let lines =<< trim END
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
+ endfunc
+ set omnifunc=Omni_test
+ hi Normal ctermbg=blue
+ hi CursorLine cterm=underline ctermbg=green
+ set cursorline
+ call setline(1, 'aaa bbb')
+ END
+ call writefile(lines, 'Xscript', 'D')
+ let buf = RunVimInTerminal('-S Xscript', {})
+
+ " when ComplMatchIns is not set, CursorLine applies normally
+ call term_sendkeys(buf, "0ea \<C-X>\<C-O>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_01', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_02', {})
+ call term_sendkeys(buf, "\<BS>\<Esc>")
+
+ " when ComplMatchIns is set, it is applied over CursorLine
+ call TermWait(buf)
+ call term_sendkeys(buf, ":hi ComplMatchIns ctermbg=red ctermfg=yellow\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, "0ea \<C-X>\<C-O>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_03', {})
+ call term_sendkeys(buf, "\<C-P>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_04', {})
+ call term_sendkeys(buf, "\<C-P>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_05', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_06', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ " Does not highlight the compl leader
+ call TermWait(buf)
+ call term_sendkeys(buf, ":set cot+=menuone,noselect\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, "S\<C-X>\<C-O>f\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_07', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
+ call term_sendkeys(buf, ":set cot+=fuzzy\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, "S\<C-X>\<C-O>f\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_08', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+ call TermWait(buf)
+
+ call term_sendkeys(buf, ":set cot-=fuzzy\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, "Sf\<C-N>")
+ call VerifyScreenDump(buf, 'Test_pum_matchins_combine_09', {})
+ call term_sendkeys(buf, "\<C-E>\<Esc>")
+
+ call StopVimInTerminal(buf)
+endfunc
+
+" this used to crash
+func Test_popup_completion_many_ctrlp()
+ new
+ let candidates=repeat(['a0'], 99)
+ call setline(1, candidates)
+ exe ":norm! VGg\<C-A>"
+ norm! G
+ call feedkeys("o" .. repeat("\<c-p>", 100), 'tx')
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_preview.vim b/test/old/testdir/test_preview.vim
index b7b908e761..422c50ac77 100644
--- a/test/old/testdir/test_preview.vim
+++ b/test/old/testdir/test_preview.vim
@@ -15,6 +15,20 @@ func Test_Psearch()
bwipe
endfunc
+func s:goto_preview_and_close()
+ " Go to the preview window
+ wincmd P
+ call assert_equal(1, &previewwindow)
+ call assert_equal('preview', win_gettype())
+
+ " Close preview window
+ wincmd z
+ call assert_equal(1, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ call assert_fails('wincmd P', 'E441:')
+endfunc
+
func Test_window_preview()
CheckFeature quickfix
@@ -23,17 +37,48 @@ func Test_window_preview()
call assert_equal(2, winnr('$'))
call assert_equal(0, &previewwindow)
- " Go to the preview window
- wincmd P
- call assert_equal(1, &previewwindow)
- call assert_equal('preview', win_gettype())
+ call s:goto_preview_and_close()
+endfunc
+
+func Test_window_preview_from_pbuffer()
+ CheckFeature quickfix
+
+ call writefile(['/* some C code */'], 'Xpreview.c', 'D')
+ edit Xpreview.c
+ const buf_num = bufnr('%')
+ enew
+
+ call feedkeys(":pbuffer Xpre\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"pbuffer Xpreview.c", @:)
- " Close preview window
- wincmd z
call assert_equal(1, winnr('$'))
+ exe 'pbuffer ' . buf_num
+ call assert_equal(2, winnr('$'))
call assert_equal(0, &previewwindow)
- call assert_fails('wincmd P', 'E441:')
+ call s:goto_preview_and_close()
+
+ call assert_equal(1, winnr('$'))
+ pbuffer Xpreview.c
+ call assert_equal(2, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ call s:goto_preview_and_close()
+endfunc
+
+func Test_window_preview_terminal()
+ CheckFeature quickfix
+ " CheckFeature terminal
+
+ " term ++curwin
+ term
+ const buf_num = bufnr('$')
+ call assert_equal(1, winnr('$'))
+ exe 'pbuffer' . buf_num
+ call assert_equal(2, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ call s:goto_preview_and_close()
endfunc
func Test_window_preview_from_help()
diff --git a/test/old/testdir/test_python3.vim b/test/old/testdir/test_python3.vim
index c9dbc0b84e..2436587100 100644
--- a/test/old/testdir/test_python3.vim
+++ b/test/old/testdir/test_python3.vim
@@ -284,7 +284,10 @@ s+='B'
python3 << trim eof
s+='E'
eof
- call assert_equal('ABCDE', pyxeval('s'))
+ python3 << trimm
+s+='F'
+trimm
+ call assert_equal('ABCDEF', pyxeval('s'))
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_pyx3.vim b/test/old/testdir/test_pyx3.vim
index 89a3cc22ff..8dfeaff807 100644
--- a/test/old/testdir/test_pyx3.vim
+++ b/test/old/testdir/test_pyx3.vim
@@ -97,7 +97,10 @@ result+='B'
pyx << trim eof
result+='E'
eof
- call assert_equal('ABCDE', pyxeval('result'))
+ pyx << trimm
+result+='F'
+trimm
+ call assert_equal('ABCDEF', pyxeval('result'))
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_ruby.vim b/test/old/testdir/test_ruby.vim
index d4a3dc3301..94941da873 100644
--- a/test/old/testdir/test_ruby.vim
+++ b/test/old/testdir/test_ruby.vim
@@ -282,7 +282,7 @@ func Test_ruby_Vim_buffer_get()
call assert_match('Xfoo1$', rubyeval('Vim::Buffer[1].name'))
call assert_match('Xfoo2$', rubyeval('Vim::Buffer[2].name'))
call assert_fails('ruby print Vim::Buffer[3].name',
- \ "NoMethodError: undefined method `name' for nil")
+ \ "NoMethodError")
%bwipe
endfunc
@@ -364,7 +364,7 @@ func Test_ruby_Vim_evaluate_dict()
redir => l:out
ruby d = Vim.evaluate("d"); print d
redir END
- call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
+ call assert_equal(['{"a"=>"foo","b"=>123}'], split(substitute(l:out, '\s', '', 'g'), "\n"))
endfunc
" Test Vim::message({msg}) (display message {msg})
@@ -384,7 +384,7 @@ func Test_ruby_print()
call assert_equal('1.23', RubyPrint('1.23'))
call assert_equal('Hello World!', RubyPrint('"Hello World!"'))
call assert_equal('[1, 2]', RubyPrint('[1, 2]'))
- call assert_equal('{"k1"=>"v1", "k2"=>"v2"}', RubyPrint('({"k1" => "v1", "k2" => "v2"})'))
+ call assert_equal('{"k1"=>"v1","k2"=>"v2"}', substitute(RubyPrint('({"k1" => "v1", "k2" => "v2"})'), '\s', '', 'g'))
call assert_equal('true', RubyPrint('true'))
call assert_equal('false', RubyPrint('false'))
call assert_equal('', RubyPrint('nil'))
@@ -439,7 +439,10 @@ Vim.command('let s ..= "B"')
ruby << trim eof
Vim.command('let s ..= "E"')
eof
- call assert_equal('ABCDE', s)
+ruby << trimm
+Vim.command('let s ..= "F"')
+trimm
+ call assert_equal('ABCDEF', s)
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_shift.vim b/test/old/testdir/test_shift.vim
index ec357dac88..f31c5a11e6 100644
--- a/test/old/testdir/test_shift.vim
+++ b/test/old/testdir/test_shift.vim
@@ -108,10 +108,809 @@ func Test_ex_shift_errors()
call assert_fails('>!', 'E477:')
call assert_fails('<!', 'E477:')
- " call assert_fails('2,1>', 'E493:')
- call assert_fails('execute "2,1>"', 'E493:')
- " call assert_fails('2,1<', 'E493:')
- call assert_fails('execute "2,1<"', 'E493:')
+ call assert_fails('2,1>', 'E493:')
+ call assert_fails('2,1<', 'E493:')
+endfunc
+
+" Test inserting a backspace at the start of a line.
+"
+" This is to verify the proper behavior of tabstop_start() as called from
+" ins_bs().
+"
+func Test_shift_ins_bs()
+ set backspace=indent,start
+ set softtabstop=11
+
+ call setline(1, repeat(" ", 33) . "word")
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 22) . "word", getline(1))
+ call setline(1, repeat(" ", 23) . "word")
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 22) . "word", getline(1))
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 11) . "word", getline(1))
+
+ set backspace& softtabstop&
+ bw!
+endfunc
+
+" Test inserting a backspace at the start of a line, with 'varsofttabstop'.
+"
+func Test_shift_ins_bs_vartabs()
+ CheckFeature vartabs
+ set backspace=indent,start
+ set varsofttabstop=13,11,7
+
+ call setline(1, repeat(" ", 44) . "word")
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 38) . "word", getline(1))
+ call setline(1, repeat(" ", 39) . "word")
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 38) . "word", getline(1))
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 31) . "word", getline(1))
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 24) . "word", getline(1))
+ exe "norm! I\<BS>"
+ call assert_equal(repeat(" ", 13) . "word", getline(1))
+ exe "norm! I\<BS>"
+ call assert_equal( "word", getline(1))
+ exe "norm! I\<BS>"
+ call assert_equal( "word", getline(1))
+
+ set backspace& varsofttabstop&
+ bw!
+endfunc
+
+" Test the >> and << normal-mode commands.
+"
+func Test_shift_norm()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=5
+ set tabstop=7
+
+ call setline(1, " word")
+
+ " Shift by 'shiftwidth' right and left.
+
+ norm! >>
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 12) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 17) . "word", getline(1))
+
+ norm! <<
+ call assert_equal(repeat(" ", 12) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, " word")
+
+ norm! >>
+ call assert_equal(repeat(" ", 9) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 16) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 23) . "word", getline(1))
+
+ norm! <<
+ call assert_equal(repeat(" ", 16) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 9) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test the >> and << normal-mode commands, with 'vartabstop'.
+"
+func Test_shift_norm_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, " word")
+
+ norm! >>
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 38) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 49) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 60) . "word", getline(1))
+
+ norm! <<
+ call assert_equal(repeat(" ", 49) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 38) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& vartabstop&
+ bw!
+endfunc
+
+" Test the >> and << normal-mode commands with 'shiftround'.
+"
+func Test_shift_norm_round()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftround
+ set shiftwidth=5
+ set tabstop=7
+
+ call setline(1, "word")
+
+ " Shift by 'shiftwidth' right and left.
+
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 5) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 20) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 25) . "word", getline(1))
+
+ norm! <<
+ call assert_equal(repeat(" ", 20) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+ exe "norm! I "
+ norm! <<
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+
+ call setline(1, repeat(" ", 7) . "word")
+ norm! <<
+ call assert_equal(repeat(" ", 5) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ call setline(1, repeat(" ", 2) . "word")
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, "word")
+
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 14) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 28) . "word", getline(1))
+ norm! >>
+ call assert_equal(repeat(" ", 35) . "word", getline(1))
+
+ norm! <<
+ call assert_equal(repeat(" ", 28) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 14) . "word", getline(1))
+ exe "norm! I "
+ norm! <<
+ call assert_equal(repeat(" ", 14) . "word", getline(1))
+
+ call setline(1, repeat(" ", 9) . "word")
+ norm! <<
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ call setline(1, repeat(" ", 2) . "word")
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftround& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test the >> and << normal-mode commands with 'shiftround' and 'vartabstop'.
+"
+func Test_shift_norm_round_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftround
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, "word")
+
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 36) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+ exe "norm! I "
+ norm! >>
+ call assert_equal(repeat(" ", 58) . "word", getline(1))
+
+ exe "norm! I "
+ norm! <<
+ call assert_equal(repeat(" ", 58) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 36) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I "
+ norm! <<
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ exe "norm! I "
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftround& shiftwidth& vartabstop&
+ bw!
+endfunc
+
+" Test the V> and V< visual-mode commands.
+"
+" See ":help v_<" and ":help v_>". See also the last paragraph of "3. Simple
+" changes", ":help simple-change", immediately above "4. Complex changes",
+" ":help complex-change".
+"
+func Test_shift_vis()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=5
+ set tabstop=7
+
+ call setline(1, " word")
+
+ " Shift by 'shiftwidth' right and left.
+
+ norm! V>
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ norm! V2>
+ call assert_equal(repeat(" ", 17) . "word", getline(1))
+ norm! V3>
+ call assert_equal(repeat(" ", 32) . "word", getline(1))
+
+ norm! V<
+ call assert_equal(repeat(" ", 27) . "word", getline(1))
+ norm! V2<
+ call assert_equal(repeat(" ", 17) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, " word")
+
+ norm! V>
+ call assert_equal(repeat(" ", 9) . "word", getline(1))
+ norm! V2>
+ call assert_equal(repeat(" ", 23) . "word", getline(1))
+ norm! V3>
+ call assert_equal(repeat(" ", 44) . "word", getline(1))
+
+ norm! V<
+ call assert_equal(repeat(" ", 37) . "word", getline(1))
+ norm! V2<
+ call assert_equal(repeat(" ", 23) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test the V> and V< visual-mode commands, with 'vartabstop'.
+"
+" See ":help v_<" and ":help v_>". See also the last paragraph of "3. Simple
+" changes", ":help simple-change", immediately above "4. Complex changes",
+" ":help complex-change".
+"
+func Test_shift_vis_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, " word")
+
+ norm! V>
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ norm! V2>
+ call assert_equal(repeat(" ", 49) . "word", getline(1))
+ norm! V3>
+ call assert_equal(repeat(" ", 82) . "word", getline(1))
+
+ norm! V<
+ call assert_equal(repeat(" ", 71) . "word", getline(1))
+ norm! V2<
+ call assert_equal(repeat(" ", 49) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& vartabstop&
+ bw!
+endfunc
+
+" Test the V> and V< visual-mode commands with 'shiftround'.
+"
+func Test_shift_vis_round()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftround
+ set shiftwidth=5
+ set tabstop=7
+
+ call setline(1, "word")
+
+ " Shift by 'shiftwidth' right and left.
+
+ exe "norm! I "
+ norm! V>
+ call assert_equal(repeat(" ", 5) . "word", getline(1))
+ exe "norm! I "
+ norm! V2>
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ exe "norm! I "
+ norm! V3>
+ call assert_equal(repeat(" ", 30) . "word", getline(1))
+
+ exe "norm! I "
+ norm! V2<
+ call assert_equal(repeat(" ", 25) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 5) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, "word")
+
+ exe "norm! I "
+ norm! V>
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ exe "norm! I "
+ norm! V2>
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ exe "norm! I "
+ norm! V3>
+ call assert_equal(repeat(" ", 42) . "word", getline(1))
+
+ exe "norm! I "
+ norm! V<
+ call assert_equal(repeat(" ", 42) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 35) . "word", getline(1))
+ norm! V2<
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ call setline(1, " word")
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+
+ set expandtab& shiftround& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test the V> and V< visual-mode commands with 'shiftround' and 'vartabstop'.
+"
+func Test_shift_vis_round_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftround
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, "word")
+
+ exe "norm! I "
+ norm! V>
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I "
+ norm! V3>
+ call assert_equal(repeat(" ", 58) . "word", getline(1))
+
+ exe "norm! I "
+ norm! V2<
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+ exe "norm! I "
+ norm! V3<
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I "
+ norm! V3<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ exe "norm! I "
+ norm! V<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftround& shiftwidth& vartabstop&
+ bw!
+endfunc
+
+" Test the :> and :< ex-mode commands.
+"
+func Test_shift_ex()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=5
+ set tabstop=7
+
+ call setline(1, " word")
+
+ " Shift by 'shiftwidth' right and left.
+
+ >
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ >>
+ call assert_equal(repeat(" ", 17) . "word", getline(1))
+ >>>
+ call assert_equal(repeat(" ", 32) . "word", getline(1))
+
+ <<<<
+ call assert_equal(repeat(" ", 12) . "word", getline(1))
+ <
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ <
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ <
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, " word")
+
+ >
+ call assert_equal(repeat(" ", 9) . "word", getline(1))
+ >>
+ call assert_equal(repeat(" ", 23) . "word", getline(1))
+ >>>
+ call assert_equal(repeat(" ", 44) . "word", getline(1))
+
+ <<<<
+ call assert_equal(repeat(" ", 16) . "word", getline(1))
+ <<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ <
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test the :> and :< ex-mode commands, with vartabstop.
+"
+func Test_shift_ex_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, " word")
+
+ >
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ >>
+ call assert_equal(repeat(" ", 49) . "word", getline(1))
+ >>>
+ call assert_equal(repeat(" ", 82) . "word", getline(1))
+
+ <<<<
+ call assert_equal(repeat(" ", 38) . "word", getline(1))
+ <<
+ call assert_equal(repeat(" ", 2) . "word", getline(1))
+ <
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& vartabstop&
+ bw!
+endfunc
+
+" Test the :> and :< ex-mode commands with 'shiftround'.
+"
+func Test_shift_ex_round()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftround
+ set shiftwidth=5
+ set tabstop=7
+
+ call setline(1, "word")
+
+ " Shift by 'shiftwidth' right and left.
+
+ exe "norm! I "
+ >
+ call assert_equal(repeat(" ", 5) . "word", getline(1))
+ exe "norm! I "
+ >>
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ exe "norm! I "
+ >>>
+ call assert_equal(repeat(" ", 30) . "word", getline(1))
+
+ exe "norm! I "
+ <<<<
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ exe "norm! I "
+ <<
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+ <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ >>
+ <<<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, "word")
+
+ exe "norm! I "
+ >
+ call assert_equal(repeat(" ", 7) . "word", getline(1))
+ exe "norm! I "
+ >>
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ exe "norm! I "
+ >>>
+ call assert_equal(repeat(" ", 42) . "word", getline(1))
+
+ exe "norm! I "
+ <<<<
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ exe "norm! I "
+ <<
+ call assert_equal(repeat(" ", 14) . "word", getline(1))
+ exe "norm! I "
+ <<<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ >>
+ <<<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftround& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test the :> and :< ex-mode commands with 'shiftround' and 'vartabstop'.
+"
+func Test_shift_ex_round_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftround
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, "word")
+
+ exe "norm! I "
+ >
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I "
+ >>
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+ >>>
+ call assert_equal(repeat(" ", 80) . "word", getline(1))
+
+ <<<<
+ call assert_equal(repeat(" ", 36) . "word", getline(1))
+ exe "norm! I "
+ <<
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I "
+ <<
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ <
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftround& shiftwidth& vartabstop&
+ bw!
+endfunc
+
+" Test shifting lines with <C-T> and <C-D>.
+"
+func Test_shift_ins()
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=5
+ set tabstop=7
+
+ " Shift by 'shiftwidth' right and left.
+
+ call setline(1, repeat(" ", 7) . "word")
+ exe "norm! 9|i\<C-T>"
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+ exe "norm! A\<C-T>"
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ exe "norm! I \<C-T>"
+ call assert_equal(repeat(" ", 20) . "word", getline(1))
+
+ exe "norm! I \<C-D>"
+ call assert_equal(repeat(" ", 20) . "word", getline(1))
+ exe "norm! I "
+ exe "norm! 24|i\<C-D>"
+ call assert_equal(repeat(" ", 20) . "word", getline(1))
+ exe "norm! A\<C-D>"
+ call assert_equal(repeat(" ", 15) . "word", getline(1))
+ exe "norm! I "
+ exe "norm! A\<C-D>\<C-D>"
+ call assert_equal(repeat(" ", 10) . "word", getline(1))
+ exe "norm! I\<C-D>\<C-D>\<C-D>"
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ exe "norm! I\<C-D>"
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ " Shift by 'tabstop' right and left.
+
+ set shiftwidth=0
+ call setline(1, "word")
+
+ call setline(1, repeat(" ", 9) . "word")
+ exe "norm! 11|i\<C-T>"
+ call assert_equal(repeat(" ", 14) . "word", getline(1))
+ exe "norm! A\<C-T>"
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ exe "norm! I \<C-T>"
+ call assert_equal(repeat(" ", 28) . "word", getline(1))
+
+ exe "norm! I \<C-D>"
+ call assert_equal(repeat(" ", 28) . "word", getline(1))
+ exe "norm! I "
+ exe "norm! 32|i\<C-D>"
+ call assert_equal(repeat(" ", 28) . "word", getline(1))
+ exe "norm! A\<C-D>"
+ call assert_equal(repeat(" ", 21) . "word", getline(1))
+ exe "norm! I "
+ exe "norm! A\<C-D>\<C-D>"
+ call assert_equal(repeat(" ", 14) . "word", getline(1))
+ exe "norm! I\<C-D>\<C-D>\<C-D>"
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ exe "norm! I\<C-D>"
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& tabstop&
+ bw!
+endfunc
+
+" Test shifting lines with <C-T> and <C-D>, with 'vartabstop'.
+"
+func Test_shift_ins_vartabs()
+ CheckFeature vartabs
+ set expandtab " Don't want to worry about tabs vs. spaces in
+ " results.
+
+ set shiftwidth=0
+ set vartabstop=19,17,11
+
+ " Shift by 'vartabstop' right and left.
+
+ call setline(1, "word")
+
+ call setline(1, repeat(" ", 9) . "word")
+ exe "norm! 11|i\<C-T>"
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! A\<C-T>"
+ call assert_equal(repeat(" ", 36) . "word", getline(1))
+ exe "norm! I \<C-T>"
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+
+ exe "norm! I \<C-D>"
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+ exe "norm! I "
+ exe "norm! 51|i\<C-D>"
+ call assert_equal(repeat(" ", 47) . "word", getline(1))
+ exe "norm! A\<C-D>"
+ call assert_equal(repeat(" ", 36) . "word", getline(1))
+ exe "norm! I "
+ exe "norm! A\<C-D>\<C-D>"
+ call assert_equal(repeat(" ", 19) . "word", getline(1))
+ exe "norm! I\<C-D>\<C-D>\<C-D>"
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+ exe "norm! I\<C-D>"
+ call assert_equal(repeat(" ", 0) . "word", getline(1))
+
+ set expandtab& shiftwidth& vartabstop&
+ bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_spell.vim b/test/old/testdir/test_spell.vim
index bdd8a673fd..a5ae653369 100644
--- a/test/old/testdir/test_spell.vim
+++ b/test/old/testdir/test_spell.vim
@@ -471,7 +471,9 @@ func Test_spellsuggest_option_number()
\ .. "Change \"baord\" to:\n"
\ .. " 1 \"board\"\n"
\ .. " 2 \"bard\"\n"
- \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
+ "\ Nvim: Prompt message is sent to cmdline prompt.
+ "\ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
+ \ , a)
set spell spellsuggest=0
call assert_equal("\nSorry, no suggestions", execute('norm $z='))
@@ -509,7 +511,9 @@ func Test_spellsuggest_option_expr()
\ .. " 1 \"BARD\"\n"
\ .. " 2 \"BOARD\"\n"
\ .. " 3 \"BROAD\"\n"
- \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
+ "\ Nvim: Prompt message is sent to cmdline prompt.
+ "\ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
+ \ , a)
" With verbose, z= should show the score i.e. word length with
" our SpellSuggest() function.
@@ -521,7 +525,9 @@ func Test_spellsuggest_option_expr()
\ .. " 1 \"BARD\" (4 - 0)\n"
\ .. " 2 \"BOARD\" (5 - 0)\n"
\ .. " 3 \"BROAD\" (5 - 0)\n"
- \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
+ "\ Nvim: Prompt message is sent to cmdline prompt.
+ "\ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
+ \ , a)
set spell& spellsuggest& verbose&
bwipe!
diff --git a/test/old/testdir/test_stacktrace.vim b/test/old/testdir/test_stacktrace.vim
new file mode 100644
index 0000000000..9e1f51e1f6
--- /dev/null
+++ b/test/old/testdir/test_stacktrace.vim
@@ -0,0 +1,142 @@
+" Test for getstacktrace() and v:stacktrace
+
+source vim9.vim
+
+let s:thisfile = expand('%:p')
+let s:testdir = s:thisfile->fnamemodify(':h')
+
+func Filepath(name)
+ return s:testdir .. '/' .. a:name
+endfunc
+
+func AssertStacktrace(expect, actual)
+ call assert_equal(Filepath('runtest.vim'), a:actual[0]['filepath'])
+ call assert_equal(a:expect, a:actual[-len(a:expect):])
+endfunc
+
+func Test_getstacktrace()
+ let g:stacktrace = []
+ let lines1 =<< trim [SCRIPT]
+ " Xscript1
+ source Xscript2
+ func Xfunc1()
+ " Xfunc1
+ call Xfunc2()
+ endfunc
+ [SCRIPT]
+ let lines2 =<< trim [SCRIPT]
+ " Xscript2
+ func Xfunc2()
+ " Xfunc2
+ let g:stacktrace = getstacktrace()
+ endfunc
+ [SCRIPT]
+ call writefile(lines1, 'Xscript1', 'D')
+ call writefile(lines2, 'Xscript2', 'D')
+ source Xscript1
+ call Xfunc1()
+ call AssertStacktrace([
+ \ #{funcref: funcref('Test_getstacktrace'), lnum: 37, filepath: s:thisfile},
+ \ #{funcref: funcref('Xfunc1'), lnum: 5, filepath: Filepath('Xscript1')},
+ \ #{funcref: funcref('Xfunc2'), lnum: 4, filepath: Filepath('Xscript2')},
+ \ ], g:stacktrace)
+ unlet g:stacktrace
+endfunc
+
+func Test_getstacktrace_event()
+ let g:stacktrace = []
+ let lines1 =<< trim [SCRIPT]
+ " Xscript1
+ func Xfunc()
+ " Xfunc
+ let g:stacktrace = getstacktrace()
+ endfunc
+ augroup test_stacktrace
+ autocmd SourcePre * call Xfunc()
+ augroup END
+ [SCRIPT]
+ let lines2 =<< trim [SCRIPT]
+ " Xscript2
+ [SCRIPT]
+ call writefile(lines1, 'Xscript1', 'D')
+ call writefile(lines2, 'Xscript2', 'D')
+ source Xscript1
+ source Xscript2
+ call AssertStacktrace([
+ \ #{funcref: funcref('Test_getstacktrace_event'), lnum: 64, filepath: s:thisfile},
+ \ #{event: 'SourcePre Autocommands for "*"', lnum: 7, filepath: Filepath('Xscript1')},
+ \ #{funcref: funcref('Xfunc'), lnum: 4, filepath: Filepath('Xscript1')},
+ \ ], g:stacktrace)
+ augroup test_stacktrace
+ autocmd!
+ augroup END
+ unlet g:stacktrace
+endfunc
+
+func Test_vstacktrace()
+ let lines1 =<< trim [SCRIPT]
+ " Xscript1
+ source Xscript2
+ func Xfunc1()
+ " Xfunc1
+ call Xfunc2()
+ endfunc
+ [SCRIPT]
+ let lines2 =<< trim [SCRIPT]
+ " Xscript2
+ func Xfunc2()
+ " Xfunc2
+ throw 'Exception from Xfunc2'
+ endfunc
+ [SCRIPT]
+ call writefile(lines1, 'Xscript1', 'D')
+ call writefile(lines2, 'Xscript2', 'D')
+ source Xscript1
+ call assert_equal([], v:stacktrace)
+ try
+ call Xfunc1()
+ catch
+ let stacktrace = v:stacktrace
+ try
+ call Xfunc1()
+ catch
+ let stacktrace_inner = v:stacktrace
+ endtry
+ let stacktrace_after = v:stacktrace " should be restored by the exception stack to the previous one
+ endtry
+ call assert_equal([], v:stacktrace)
+ call AssertStacktrace([
+ \ #{funcref: funcref('Test_vstacktrace'), lnum: 97, filepath: s:thisfile},
+ \ #{funcref: funcref('Xfunc1'), lnum: 5, filepath: Filepath('Xscript1')},
+ \ #{funcref: funcref('Xfunc2'), lnum: 4, filepath: Filepath('Xscript2')},
+ \ ], stacktrace)
+ call AssertStacktrace([
+ \ #{funcref: funcref('Test_vstacktrace'), lnum: 101, filepath: s:thisfile},
+ \ #{funcref: funcref('Xfunc1'), lnum: 5, filepath: Filepath('Xscript1')},
+ \ #{funcref: funcref('Xfunc2'), lnum: 4, filepath: Filepath('Xscript2')},
+ \ ], stacktrace_inner)
+ call assert_equal(stacktrace, stacktrace_after)
+endfunc
+
+func Test_stacktrace_vim9()
+ let lines =<< trim [SCRIPT]
+ var stacktrace = getstacktrace()
+ assert_notequal([], stacktrace)
+ for d in stacktrace
+ assert_true(has_key(d, 'lnum'))
+ endfor
+ try
+ throw 'Exception from s:Func'
+ catch
+ assert_notequal([], v:stacktrace)
+ assert_equal(len(stacktrace), len(v:stacktrace))
+ for d in v:stacktrace
+ assert_true(has_key(d, 'lnum'))
+ endfor
+ endtry
+ call assert_equal([], v:stacktrace)
+ [SCRIPT]
+ call CheckDefSuccess(lines)
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_statusline.vim b/test/old/testdir/test_statusline.vim
index c8162ced07..c9f79dfef7 100644
--- a/test/old/testdir/test_statusline.vim
+++ b/test/old/testdir/test_statusline.vim
@@ -220,6 +220,10 @@ func Test_statusline()
wincmd j
call assert_match('^\[Preview\],PRV\s*$', s:get_statusline())
pclose
+ pbuffer
+ wincmd j
+ call assert_match('^\[Preview\],PRV\s*$', s:get_statusline())
+ pclose
" %y: Type of file in the buffer, e.g., "[vim]". See 'filetype'.
" %Y: Type of file in the buffer, e.g., ",VIM". See 'filetype'.
diff --git a/test/old/testdir/test_tagjump.vim b/test/old/testdir/test_tagjump.vim
index 470c5c43b4..efc5e4cebe 100644
--- a/test/old/testdir/test_tagjump.vim
+++ b/test/old/testdir/test_tagjump.vim
@@ -1231,8 +1231,10 @@ func Test_tselect_listing()
2 FS v first Xfoo
typeref:typename:char
2
-Type number and <Enter> (q or empty cancels):
[DATA]
+" Type number and <Enter> (q or empty cancels):
+" Nvim: Prompt message is sent to cmdline prompt.
+
call assert_equal(expected, l)
call delete('Xtags')
diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim
index eb88ea6f5f..6ff233fff0 100644
--- a/test/old/testdir/test_termdebug.vim
+++ b/test/old/testdir/test_termdebug.vim
@@ -391,7 +391,8 @@ endfunc
function Test_termdebug_save_restore_variables()
" saved mousemodel
- let &mousemodel=''
+ "let &mousemodel=''
+ let &mousemodel='extend'
" saved keys
nnoremap K :echo "hello world!"<cr>
@@ -414,7 +415,8 @@ function Test_termdebug_save_restore_variables()
quit!
call WaitForAssert({-> assert_equal(1, winnr('$'))})
- call assert_true(empty(&mousemodel))
+ "call assert_true(empty(&mousemodel))
+ call assert_equal(&mousemodel, 'extend')
call assert_true(empty(expected_map_minus))
call assert_equal(expected_map_K.rhs, maparg('K', 'n', 0, 1).rhs)
diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim
index 3c24412eb7..b1543c8f24 100644
--- a/test/old/testdir/test_user_func.vim
+++ b/test/old/testdir/test_user_func.vim
@@ -380,7 +380,7 @@ func Test_script_local_func()
" Try to call a script local function in global scope
let lines =<< trim [CODE]
:call assert_fails('call s:Xfunc()', 'E81:')
- :call assert_fails('let x = call("<SID>Xfunc", [])', 'E120:')
+ :call assert_fails('let x = call("<SID>Xfunc", [])', ['E81:', 'E117:'])
:call writefile(v:errors, 'Xresult')
:qall
@@ -421,12 +421,48 @@ func Test_func_def_error()
call assert_fails('exe l', 'E717:')
" Define an autoload function with an incorrect file name
- call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript')
+ call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript', 'D')
call assert_fails('source Xscript', 'E746:')
- call delete('Xscript')
" Try to list functions using an invalid search pattern
call assert_fails('function /\%(/', 'E53:')
+
+ " Use a script-local function to cover uf_name_exp.
+ func s:TestRedefine(arg1 = 1, arg2 = 10)
+ let caught_E122 = 0
+ try
+ func s:TestRedefine(arg1 = 1, arg2 = 10)
+ endfunc
+ catch /E122:/
+ let caught_E122 = 1
+ endtry
+ call assert_equal(1, caught_E122)
+
+ let caught_E127 = 0
+ try
+ func! s:TestRedefine(arg1 = 1, arg2 = 10)
+ endfunc
+ catch /E127:/
+ let caught_E127 = 1
+ endtry
+ call assert_equal(1, caught_E127)
+
+ " The failures above shouldn't cause heap-use-after-free here.
+ return [a:arg1 + a:arg2, expand('<stack>')]
+ endfunc
+
+ let stacks = []
+ " Call the function twice.
+ " Failing to redefine a function shouldn't clear its argument list.
+ for i in range(2)
+ let [val, stack] = s:TestRedefine(1000)
+ call assert_equal(1010, val)
+ call assert_match(expand('<SID>') .. 'TestRedefine\[20\]$', stack)
+ call add(stacks, stack)
+ endfor
+ call assert_equal(stacks[0], stacks[1])
+
+ delfunc s:TestRedefine
endfunc
" Test for deleting a function
@@ -910,4 +946,36 @@ func Test_func_curly_brace_invalid_name()
delfunc Fail
endfunc
+func Test_func_return_in_try_verbose()
+ func TryReturnList()
+ try
+ return [1, 2, 3]
+ endtry
+ endfunc
+ func TryReturnNumber()
+ try
+ return 123
+ endtry
+ endfunc
+ func TryReturnOverlongString()
+ try
+ return repeat('a', 9999)
+ endtry
+ endfunc
+
+ " This should not cause heap-use-after-free
+ call assert_match('\n:return \[1, 2, 3\] made pending\n',
+ \ execute('14verbose call TryReturnList()'))
+ " This should not cause stack-use-after-scope
+ call assert_match('\n:return 123 made pending\n',
+ \ execute('14verbose call TryReturnNumber()'))
+ " An overlong string is truncated
+ call assert_match('\n:return a\{100,}\.\.\.',
+ \ execute('14verbose call TryReturnOverlongString()'))
+
+ delfunc TryReturnList
+ delfunc TryReturnNumber
+ delfunc TryReturnOverlongString
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim
index e25327ddd4..328ac502bf 100644
--- a/test/old/testdir/test_visual.vim
+++ b/test/old/testdir/test_visual.vim
@@ -470,7 +470,7 @@ func Test_Visual_Block()
\ "\t{",
\ "\t}"], getline(1, '$'))
- close!
+ bw!
endfunc
" Test for 'p'ut in visual block mode
@@ -1082,7 +1082,7 @@ func Test_star_register()
delmarks < >
call assert_fails('*yank', 'E20:')
- close!
+ bw!
endfunc
" Test for changing text in visual mode with 'exclusive' selection
@@ -1098,7 +1098,7 @@ func Test_exclusive_selection()
call assert_equal('l one', getline(1))
set virtualedit&
set selection&
- close!
+ bw!
endfunc
" Test for starting linewise visual with a count.
@@ -1155,7 +1155,7 @@ func Test_visual_inner_block()
8,9d
call cursor(5, 1)
call assert_beeps('normal ViBiB')
- close!
+ bw!
endfunc
func Test_visual_put_in_block()
@@ -2718,4 +2718,68 @@ func Test_visual_block_cursor_insert_enter()
bwipe!
endfunc
+func Test_visual_block_exclusive_selection()
+ new
+ set selection=exclusive
+ call setline(1, ['asöd asdf', 'asdf asdf', 'as€d asdf', 'asdf asdf'])
+ call cursor(1, 1)
+ exe ":norm! \<c-v>eh3j~"
+ call assert_equal(['ASÖd asdf', 'ASDf asdf', 'AS€d asdf', 'ASDf asdf'], getline(1, '$'))
+ exe ":norm! 1v~"
+ call assert_equal(['asöd asdf', 'asdf asdf', 'as€d asdf', 'asdf asdf'], getline(1, '$'))
+ bwipe!
+ set selection&vim
+endfunc
+
+func Test_visual_block_exclusive_selection_adjusted()
+ new
+ " Test that the end-position of the visual selection is adjusted for exclusive selection
+ set selection=exclusive
+ call setline(1, ['asöd asdf ', 'asdf asdf ', 'as€d asdf ', 'asdf asdf '])
+ call cursor(1, 1)
+ " inclusive motion
+ exe ":norm! \<c-v>e3jy"
+ call assert_equal([0, 4, 5, 0], getpos("'>"))
+ " exclusive motion
+ exe ":norm! \<c-v>ta3jy"
+ call assert_equal([0, 4, 6, 0], getpos("'>"))
+ " another inclusive motion
+ exe ":norm! \<c-v>g_3jy"
+ call assert_equal([0, 4, 10, 0], getpos("'>"))
+
+ " Reset selection option to Vim default
+ set selection&vim
+ call cursor(1, 1)
+
+ " inclusive motion
+ exe ":norm! \<c-v>e3jy"
+ call assert_equal([0, 4, 4, 0], getpos("'>"))
+ " exclusive motion
+ exe ":norm! \<c-v>ta3jy"
+ call assert_equal([0, 4, 5, 0], getpos("'>"))
+ " another inclusive motion
+ exe ":norm! \<c-v>g_3jy"
+ call assert_equal([0, 4, 9, 0], getpos("'>"))
+ bwipe!
+ set selection&vim
+endfunc
+
+" the following caused a Heap-Overflow, because Vim was accessing outside of a
+" line end
+func Test_visual_pos_buffer_heap_overflow()
+ set virtualedit=all
+ args Xa Xb
+ all
+ call setline(1, ['', '', ''])
+ call cursor(3, 1)
+ wincmd w
+ call setline(1, 'foobar')
+ normal! $lv0
+ all
+ call setreg('"', 'baz')
+ normal! [P
+ set virtualedit=
+ bw! Xa Xb
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 8048fa6ff8..24517f90cb 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -55,6 +55,26 @@ func Test_window_cmd_cmdwin_with_vsp()
set ls&vim
endfunc
+func Test_cmdheight_not_changed()
+ set cmdheight=2
+ set winminheight=0
+ augroup Maximize
+ autocmd WinEnter * wincmd _
+ augroup END
+ split
+ tabnew
+ tabfirst
+ call assert_equal(2, &cmdheight)
+
+ tabonly!
+ only
+ set winminheight& cmdheight&
+ augroup Maximize
+ au!
+ augroup END
+ augroup! Maximize
+endfunc
+
" Test for jumping to windows
func Test_window_jump()
new
@@ -1164,20 +1184,20 @@ func Run_noroom_for_newwindow_test(dir_arg)
let dir = (a:dir_arg == 'v') ? 'vert ' : ''
" Open as many windows as possible
- for i in range(500)
+ while v:true
try
exe dir . 'new'
catch /E36:/
break
endtry
- endfor
+ endwhile
- call writefile(['first', 'second', 'third'], 'Xfile1')
- call writefile([], 'Xfile2')
- call writefile([], 'Xfile3')
+ call writefile(['first', 'second', 'third'], 'Xnorfile1')
+ call writefile([], 'Xnorfile2')
+ call writefile([], 'Xnorfile3')
" Argument list related commands
- args Xfile1 Xfile2 Xfile3
+ args Xnorfile1 Xnorfile2 Xnorfile3
next
for cmd in ['sargument 2', 'snext', 'sprevious', 'sNext', 'srewind',
\ 'sfirst', 'slast']
@@ -1188,13 +1208,13 @@ func Run_noroom_for_newwindow_test(dir_arg)
" Buffer related commands
set modified
hide enew
- for cmd in ['sbuffer Xfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind',
+ for cmd in ['sbuffer Xnorfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind',
\ 'sbfirst', 'sblast', 'sball', 'sbmodified', 'sunhide']
call assert_fails(dir .. cmd, 'E36:')
endfor
" Window related commands
- for cmd in ['split', 'split Xfile2', 'new', 'new Xfile3', 'sview Xfile1',
+ for cmd in ['split', 'split Xnorfile2', 'new', 'new Xnorfile3', 'sview Xnorfile1',
\ 'sfind runtest.vim']
call assert_fails(dir .. cmd, 'E36:')
endfor
@@ -1217,7 +1237,8 @@ func Run_noroom_for_newwindow_test(dir_arg)
call assert_fails(dir .. 'lopen', 'E36:')
" Preview window
- call assert_fails(dir .. 'pedit Xfile2', 'E36:')
+ call assert_fails(dir .. 'pedit Xnorfile2', 'E36:')
+ call assert_fails(dir .. 'pbuffer', 'E36:')
call setline(1, 'abc')
call assert_fails(dir .. 'psearch abc', 'E36:')
endif
@@ -1225,15 +1246,15 @@ func Run_noroom_for_newwindow_test(dir_arg)
" Window commands (CTRL-W ^ and CTRL-W f)
if a:dir_arg == 'h'
call assert_fails('call feedkeys("\<C-W>^", "xt")', 'E36:')
- call setline(1, 'Xfile1')
+ call setline(1, 'Xnorfile1')
call assert_fails('call feedkeys("gg\<C-W>f", "xt")', 'E36:')
endif
enew!
" Tag commands (:stag, :stselect and :stjump)
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
- \ "second\tXfile1\t2",
- \ "third\tXfile1\t3",],
+ \ "second\tXnorfile1\t2",
+ \ "third\tXnorfile1\t3",],
\ 'Xtags')
set tags=Xtags
call assert_fails(dir .. 'stag second', 'E36:')
@@ -1255,9 +1276,9 @@ func Run_noroom_for_newwindow_test(dir_arg)
endif
%bwipe!
- call delete('Xfile1')
- call delete('Xfile2')
- call delete('Xfile3')
+ call delete('Xnorfile1')
+ call delete('Xnorfile2')
+ call delete('Xnorfile3')
only
endfunc
diff --git a/test/old/testdir/test_winfixbuf.vim b/test/old/testdir/test_winfixbuf.vim
index 1777bec184..f7986fdda3 100644
--- a/test/old/testdir/test_winfixbuf.vim
+++ b/test/old/testdir/test_winfixbuf.vim
@@ -2545,6 +2545,18 @@ func Test_pedit()
call assert_equal(l:other, bufnr())
endfunc
+" Allow :pbuffer because, unlike :buffer, it uses a separate window
+func Test_pbuffer()
+ call s:reset_all_buffers()
+
+ let l:other = s:make_buffer_pairs()
+
+ exe 'pbuffer ' . l:other
+
+ execute "normal \<C-w>w"
+ call assert_equal(l:other, bufnr())
+endfunc
+
" Fail :pop but :pop! is allowed
func Test_pop()
call s:reset_all_buffers()
@@ -2613,7 +2625,7 @@ EOF
try
pyxdo test_winfixbuf_Test_pythonx_pyxdo_set_buffer()
- catch /pynvim\.api\.common\.NvimError: E1513:/
+ catch /pynvim\.api\.common\.NvimError: Vim:E1513:/
let l:caught = 1
endtry
@@ -2644,7 +2656,7 @@ func Test_pythonx_pyxfile()
try
pyxfile file.py
- catch /pynvim\.api\.common\.NvimError: E1513:/
+ catch /pynvim\.api\.common\.NvimError: Vim:E1513:/
let l:caught = 1
endtry
@@ -2676,7 +2688,7 @@ import vim
buffer = vim.vars["_previous_buffer"]
vim.current.buffer = vim.buffers[buffer]
EOF
- catch /pynvim\.api\.common\.NvimError: E1513:/
+ catch /pynvim\.api\.common\.NvimError: Vim:E1513:/
let l:caught = 1
endtry