aboutsummaryrefslogtreecommitdiff
path: root/test/old
diff options
context:
space:
mode:
Diffstat (limited to 'test/old')
-rw-r--r--test/old/testdir/Makefile17
-rw-r--r--test/old/testdir/crash/poc_did_set_langmap1
-rw-r--r--test/old/testdir/crash/poc_ex_substitutebin0 -> 135 bytes
-rw-r--r--test/old/testdir/crash/poc_suggest_trie_walkbin0 -> 100 bytes
-rw-r--r--test/old/testdir/crash/poc_win_enter_extbin0 -> 1958 bytes
-rw-r--r--test/old/testdir/runnvim.vim5
-rw-r--r--test/old/testdir/runtest.vim2
-rw-r--r--test/old/testdir/setup.vim3
-rw-r--r--test/old/testdir/test_autocmd.vim60
-rw-r--r--test/old/testdir/test_breakindent.vim107
-rw-r--r--test/old/testdir/test_cmdline.vim71
-rw-r--r--test/old/testdir/test_cmdwin.vim112
-rw-r--r--test/old/testdir/test_crash.vim37
-rw-r--r--test/old/testdir/test_cursor_func.vim5
-rw-r--r--test/old/testdir/test_diffmode.vim50
-rw-r--r--test/old/testdir/test_display.vim20
-rw-r--r--test/old/testdir/test_edit.vim34
-rw-r--r--test/old/testdir/test_excmd.vim22
-rw-r--r--test/old/testdir/test_filetype.vim117
-rw-r--r--test/old/testdir/test_filter_map.vim151
-rw-r--r--test/old/testdir/test_fold.vim13
-rw-r--r--test/old/testdir/test_functions.vim190
-rw-r--r--test/old/testdir/test_getvar.vim1
-rw-r--r--test/old/testdir/test_goto.vim13
-rw-r--r--test/old/testdir/test_highlight.vim21
-rw-r--r--test/old/testdir/test_ins_complete.vim29
-rw-r--r--test/old/testdir/test_lispindent.vim1
-rw-r--r--test/old/testdir/test_listchars.vim76
-rw-r--r--test/old/testdir/test_listdict.vim21
-rw-r--r--test/old/testdir/test_listlbr.vim8
-rw-r--r--test/old/testdir/test_listlbr_utf8.vim21
-rw-r--r--test/old/testdir/test_map_functions.vim2
-rw-r--r--test/old/testdir/test_mapping.vim20
-rw-r--r--test/old/testdir/test_messages.vim12
-rw-r--r--test/old/testdir/test_normal.vim48
-rw-r--r--test/old/testdir/test_number.vim71
-rw-r--r--test/old/testdir/test_options.vim90
-rw-r--r--test/old/testdir/test_popup.vim18
-rw-r--r--test/old/testdir/test_prompt_buffer.vim45
-rw-r--r--test/old/testdir/test_put.vim38
-rw-r--r--test/old/testdir/test_python3.vim2
-rw-r--r--test/old/testdir/test_pyx3.vim2
-rw-r--r--test/old/testdir/test_regexp_utf8.vim11
-rw-r--r--test/old/testdir/test_registers.vim104
-rw-r--r--test/old/testdir/test_scroll_opt.vim19
-rw-r--r--test/old/testdir/test_syntax.vim8
-rw-r--r--test/old/testdir/test_tabpage.vim115
-rw-r--r--test/old/testdir/test_tagjump.vim41
-rw-r--r--test/old/testdir/test_termdebug.vim89
-rw-r--r--test/old/testdir/test_textobjects.vim132
-rw-r--r--test/old/testdir/test_undo.vim2
-rw-r--r--test/old/testdir/test_utf8_comparisons.vim37
-rw-r--r--test/old/testdir/test_virtualedit.vim17
-rw-r--r--test/old/testdir/test_visual.vim358
-rw-r--r--test/old/testdir/test_window_cmd.vim58
-rw-r--r--test/old/testdir/vim9.vim47
56 files changed, 2372 insertions, 222 deletions
diff --git a/test/old/testdir/Makefile b/test/old/testdir/Makefile
index b5ca6a17b0..20272a24c7 100644
--- a/test/old/testdir/Makefile
+++ b/test/old/testdir/Makefile
@@ -41,13 +41,13 @@ ifdef USE_VALGRIND
--leak-check=yes \
--track-origins=yes
# VALGRIND_TOOL := exp-sgcheck
- TOOL := valgrind -q \
- -q \
- $(VALGRIND_TOOL) \
- --suppressions=../../.valgrind.supp \
- --error-exitcode=123 \
- --log-file=valgrind-\%p.$* \
- $(VGDB) \
+ TOOL := valgrind -q \
+ -q \
+ $(VALGRIND_TOOL) \
+ --suppressions=../../../src/.valgrind.supp \
+ --error-exitcode=123 \
+ --log-file=valgrind-\%p.$* \
+ $(VGDB) \
--trace-children=yes
else
ifdef USE_GDB
@@ -121,7 +121,8 @@ CLEAN_FILES := *.out \
.*.swo \
.gdbinit \
$(TMPDIR) \
- del
+ del \
+ $(ROOT)/runtime/doc/.*.swp
clean:
$(RM) -rf $(CLEAN_FILES)
diff --git a/test/old/testdir/crash/poc_did_set_langmap b/test/old/testdir/crash/poc_did_set_langmap
new file mode 100644
index 0000000000..f77145b9d1
--- /dev/null
+++ b/test/old/testdir/crash/poc_did_set_langmap
@@ -0,0 +1 @@
+se lmap=°xÿ7sil;drlmap=°xÿ7sil;drmo: pm31 3" \ No newline at end of file
diff --git a/test/old/testdir/crash/poc_ex_substitute b/test/old/testdir/crash/poc_ex_substitute
new file mode 100644
index 0000000000..bcf1286512
--- /dev/null
+++ b/test/old/testdir/crash/poc_ex_substitute
Binary files differ
diff --git a/test/old/testdir/crash/poc_suggest_trie_walk b/test/old/testdir/crash/poc_suggest_trie_walk
new file mode 100644
index 0000000000..c79b6eeb5c
--- /dev/null
+++ b/test/old/testdir/crash/poc_suggest_trie_walk
Binary files differ
diff --git a/test/old/testdir/crash/poc_win_enter_ext b/test/old/testdir/crash/poc_win_enter_ext
new file mode 100644
index 0000000000..73f53b575b
--- /dev/null
+++ b/test/old/testdir/crash/poc_win_enter_ext
Binary files differ
diff --git a/test/old/testdir/runnvim.vim b/test/old/testdir/runnvim.vim
index 2db60d05b3..578614c8a1 100644
--- a/test/old/testdir/runnvim.vim
+++ b/test/old/testdir/runnvim.vim
@@ -7,6 +7,8 @@ function s:logger.on_exit(id, data, event)
call add(self.d_events, [a:event, ['']])
endfunction
+let s:logger.env = #{VIMRUNTIME: $VIMRUNTIME}
+
" Replace non-printable chars by special sequence, or "<%x>".
let s:escaped_char = {"\n": '\n', "\r": '\r', "\t": '\t'}
function! s:escape_non_printable(char) abort
@@ -23,8 +25,7 @@ function Main()
set lines=25
set columns=80
enew
- " FIXME: using termopen() hangs on Windows CI
- let job = has('win32') ? jobstart(args, s:logger) : termopen(args, s:logger)
+ let job = termopen(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 928bf7693f..2d8ba60a7e 100644
--- a/test/old/testdir/runtest.vim
+++ b/test/old/testdir/runtest.vim
@@ -120,6 +120,8 @@ lang mess C
" Nvim: append runtime from build dir, which contains the generated doc/tags.
let &runtimepath ..= ',' .. expand($BUILD_DIR) .. '/runtime/'
+" Nvim: append libdir from build dir, which contains the bundled TS parsers.
+let &runtimepath ..= ',' .. expand($BUILD_DIR) .. '/lib/nvim/'
let s:t_bold = &t_md
let s:t_normal = &t_me
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index 7546b342e6..091fb95806 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -93,3 +93,6 @@ let $HOME = expand(getcwd() . '/XfakeHOME')
if !isdirectory($HOME)
call mkdir($HOME)
endif
+
+" Use Vim's default color scheme
+colorscheme vim
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 7926411dcd..4d88573a1f 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -2533,7 +2533,25 @@ func Test_TextChangedI_with_setline()
call assert_equal('', getline(1))
call assert_equal('', getline(2))
- call test_override('starting', 0)
+ call test_override('char_avail', 0)
+ bwipe!
+endfunc
+
+func Test_TextChanged_with_norm()
+ " For unknown reason this fails on MS-Windows
+ CheckNotMSWindows
+ CheckFeature terminal
+ let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3})
+ call assert_equal('running', term_getstatus(buf))
+ call term_sendkeys(buf, ":let g:a=0\<cr>")
+ call term_wait(buf, 50)
+ call term_sendkeys(buf, ":au! TextChanged * :let g:a+=1\<cr>")
+ call term_wait(buf, 50)
+ call term_sendkeys(buf, ":norm! ia\<cr>")
+ call term_wait(buf, 50)
+ call term_sendkeys(buf, ":echo g:a\<cr>")
+ call term_wait(buf, 50)
+ call WaitForAssert({-> assert_match('^1.*$', term_getline(buf, 3))})
bwipe!
endfunc
@@ -3822,4 +3840,44 @@ func Test_autocmd_shortmess()
delfunc SetupVimTest_shm
endfunc
+func Test_autocmd_invalidates_undo_on_textchanged()
+ CheckRunVimInTerminal
+ let script =<< trim END
+ set hidden
+ " create quickfix list (at least 2 lines to move line)
+ vimgrep /u/j %
+
+ " enter quickfix window
+ cwindow
+
+ " set modifiable
+ setlocal modifiable
+
+ " set autocmd to clear quickfix list
+
+ autocmd! TextChanged <buffer> call setqflist([])
+ " move line
+ move+1
+ END
+ call writefile(script, 'XTest_autocmd_invalidates_undo_on_textchanged', 'D')
+ let buf = RunVimInTerminal('XTest_autocmd_invalidates_undo_on_textchanged', {'rows': 20})
+ call term_sendkeys(buf, ":so %\<cr>")
+ call term_sendkeys(buf, "G")
+ call WaitForAssert({-> assert_match('^XTest_autocmd_invalidates_undo_on_textchanged\s*$', term_getline(buf, 20))}, 1000)
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_autocmd_creates_new_buffer_on_bufleave()
+ e a.txt
+ e b.txt
+ setlocal bufhidden=wipe
+ autocmd BufLeave <buffer> diffsplit c.txt
+ bn
+ call assert_equal(1, winnr('$'))
+ call assert_equal('a.txt', bufname('%'))
+ bw a.txt
+ bw c.txt
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_breakindent.vim b/test/old/testdir/test_breakindent.vim
index 301e2d0e40..636ec6f285 100644
--- a/test/old/testdir/test_breakindent.vim
+++ b/test/old/testdir/test_breakindent.vim
@@ -450,7 +450,7 @@ func Test_breakindent12()
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
- call s:close_windows('set nuw=4 listchars=')
+ call s:close_windows('set nuw=4 listchars&')
endfunc
func Test_breakindent12_vartabs()
@@ -467,7 +467,7 @@ func Test_breakindent12_vartabs()
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
- call s:close_windows('set nuw=4 listchars= vts&')
+ call s:close_windows('set nuw=4 listchars& vts&')
endfunc
func Test_breakindent13()
@@ -773,7 +773,7 @@ func Test_breakindent20_list()
\ "shall make no law ",
\ ]
call s:compare_lines(expect, lines)
- " set minimum indent
+ " set minimum text width
setl briopt=min:5
redraw!
let lines = s:screen_lines2(1, 6, 20)
@@ -963,6 +963,29 @@ func Test_cursor_position_with_showbreak()
call StopVimInTerminal(buf)
endfunc
+func Test_visual_starts_before_skipcol()
+ CheckScreendump
+
+ let lines =<< trim END
+ 1new
+ setlocal breakindent
+ call setline(1, "\t" .. join(range(100)))
+ END
+ call writefile(lines, 'XvisualStartsBeforeSkipcol', 'D')
+ let buf = RunVimInTerminal('-S XvisualStartsBeforeSkipcol', #{rows: 6})
+
+ call term_sendkeys(buf, "v$")
+ call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_1', {})
+ call term_sendkeys(buf, "\<Esc>:setlocal showbreak=+++\<CR>gv")
+ call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_2', {})
+ call term_sendkeys(buf, "\<Esc>:setlocal breakindentopt+=sbr\<CR>gv")
+ call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_3', {})
+ call term_sendkeys(buf, "\<Esc>:setlocal nobreakindent\<CR>gv")
+ call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_4', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_no_spurious_match()
let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')
@@ -1103,5 +1126,83 @@ func Test_linebreak_list()
bwipe!
endfunc
+func Test_breakindent_change_display_uhex()
+ call s:test_windows('setl briopt=min:0 list listchars=eol:$')
+ redraw!
+ let lines = s:screen_lines(line('.'), 20)
+ let expect = [
+ \ "^Iabcdefghijklmnopqr",
+ \ " stuvwxyzABCDEFGHIJ",
+ \ " KLMNOP$ "
+ \ ]
+ call s:compare_lines(expect, lines)
+ set display+=uhex
+ redraw!
+ let lines = s:screen_lines(line('.'), 20)
+ let expect = [
+ \ "<09>abcdefghijklmnop",
+ \ " qrstuvwxyzABCDEF",
+ \ " GHIJKLMNOP$ "
+ \ ]
+ call s:compare_lines(expect, lines)
+ set display&
+
+ call s:close_windows()
+endfunc
+
+func Test_breakindent_list_split()
+ 10new
+ 61vsplit
+ setlocal tabstop=8 breakindent list listchars=tab:<->,eol:$
+ put =s:input
+ 30vsplit
+ setlocal listchars=eol:$
+ let expect = [
+ \ "^IabcdefghijklmnopqrstuvwxyzAB|<------>abcdefghijklmnopqrstuv",
+ \ " CDEFGHIJKLMNOP$ | wxyzABCDEFGHIJKLMNOP$ ",
+ \ "~ |~ "
+ \ ]
+ redraw!
+ let lines = s:screen_lines(line('.'), 61)
+ call s:compare_lines(expect, lines)
+ wincmd p
+ redraw!
+ let lines = s:screen_lines(line('.'), 61)
+ call s:compare_lines(expect, lines)
+
+ bwipe!
+endfunc
+
+func Test_breakindent_min_with_signcol()
+ call s:test_windows('setl briopt=min:15 signcolumn=yes')
+ redraw!
+ let expect = [
+ \ " abcdefghijklmn",
+ \ " opqrstuvwxyzABC",
+ \ " DEFGHIJKLMNOP "
+ \ ]
+ let lines = s:screen_lines(line('.'), 20)
+ call s:compare_lines(expect, lines)
+ setl briopt=min:17
+ redraw!
+ let expect = [
+ \ " abcdefghijklmn",
+ \ " opqrstuvwxyzABCDE",
+ \ " FGHIJKLMNOP "
+ \ ]
+ let lines = s:screen_lines(line('.'), 20)
+ call s:compare_lines(expect, lines)
+ setl briopt=min:19
+ redraw!
+ let expect = [
+ \ " abcdefghijklmn",
+ \ " opqrstuvwxyzABCDEF",
+ \ " GHIJKLMNOP "
+ \ ]
+ let lines = s:screen_lines(line('.'), 20)
+ call s:compare_lines(expect, lines)
+
+ call s:close_windows()
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
index 3f13218c5b..b8eb9a2b8b 100644
--- a/test/old/testdir/test_cmdline.vim
+++ b/test/old/testdir/test_cmdline.vim
@@ -431,11 +431,11 @@ func Test_highlight_completion()
" A cleared group does not show up in completions.
hi Anders ctermfg=green
- call assert_equal(['Aardig', 'Anders'], getcompletion('A', 'highlight'))
+ call assert_equal(['Aardig', 'Added', 'Anders'], getcompletion('A', 'highlight'))
hi clear Aardig
- call assert_equal(['Anders'], getcompletion('A', 'highlight'))
+ call assert_equal(['Added', 'Anders'], getcompletion('A', 'highlight'))
hi clear Anders
- call assert_equal([], getcompletion('A', 'highlight'))
+ call assert_equal(['Added'], getcompletion('A', 'highlight'))
endfunc
func Test_getcompletion()
@@ -532,6 +532,13 @@ func Test_getcompletion()
let l = getcompletion('horse', 'filetype')
call assert_equal([], l)
+ if has('keymap')
+ let l = getcompletion('acc', 'keymap')
+ call assert_true(index(l, 'accents') >= 0)
+ let l = getcompletion('nullkeymap', 'keymap')
+ call assert_equal([], l)
+ endif
+
let l = getcompletion('z', 'syntax')
call assert_true(index(l, 'zimbu') >= 0)
let l = getcompletion('emacs', 'syntax')
@@ -672,7 +679,7 @@ func Test_getcompletion()
bw Xtest\
endif
- call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:')
+ call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E866:')
call assert_fails('call getcompletion("", "burp")', 'E475:')
call assert_fails('call getcompletion("abc", [])', 'E1174:')
endfunc
@@ -857,10 +864,28 @@ func Test_cmdline_remove_char()
let &encoding = encoding_save
endfunc
-func Test_cmdline_keymap_ctrl_hat()
- if !has('keymap')
- return
+func Test_cmdline_del_utf8()
+ let @s = '⒌'
+ call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+ call assert_equal('",,', @:)
+
+ let @s = 'a̳'
+ call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+ call assert_equal('",,', @:)
+
+ let @s = 'β̳'
+ call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+ call assert_equal('",,', @:)
+
+ if has('arabic')
+ let @s = 'لا'
+ call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+ call assert_equal('",,', @:)
endif
+endfunc
+
+func Test_cmdline_keymap_ctrl_hat()
+ CheckFeature keymap
set keymap=esperanto
call feedkeys(":\"Jxauxdo \<C-^>Jxauxdo \<C-^>Jxauxdo\<CR>", 'tx')
@@ -1878,7 +1903,7 @@ func Test_cmdwin_tabpage()
tabclose!
endfunc
-func Test_cmdwin_interrupted()
+func Test_cmdwin_interrupted_more_prompt()
CheckScreendump
" aborting the :smile output caused the cmdline window to use the current
@@ -3911,4 +3936,34 @@ func Test_custom_completion_with_glob()
delfunc TestGlobComplete
endfunc
+func Test_window_size_stays_same_after_changing_cmdheight()
+ set laststatus=2
+ let expected = winheight(0)
+ function! Function_name() abort
+ call feedkeys(":"..repeat('x', &columns), 'x')
+ let &cmdheight=2
+ let &cmdheight=1
+ redraw
+ endfunction
+ call Function_name()
+ call assert_equal(expected, winheight(0))
+endfunc
+
+" verify that buffer-completion finds all buffer names matching a pattern
+func Test_buffer_completion()
+ " should return empty list
+ call assert_equal([], getcompletion('', 'buffer'))
+
+ call mkdir('Xbuf_complete', 'R')
+ e Xbuf_complete/Foobar.c
+ e Xbuf_complete/MyFoobar.c
+ e AFoobar.h
+ let expected = ["Xbuf_complete/Foobar.c", "Xbuf_complete/MyFoobar.c", "AFoobar.h"]
+
+ call assert_equal(3, len(getcompletion('Foo', 'buffer')))
+ call assert_equal(expected, getcompletion('Foo', 'buffer'))
+ call feedkeys(":b Foo\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"b Xbuf_complete/Foobar.c Xbuf_complete/MyFoobar.c AFoobar.h", @:)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_cmdwin.vim b/test/old/testdir/test_cmdwin.vim
index f07fd99f8a..9b1a45708e 100644
--- a/test/old/testdir/test_cmdwin.vim
+++ b/test/old/testdir/test_cmdwin.vim
@@ -93,4 +93,116 @@ func Test_cmdwin_restore_heights()
set cmdheight& showtabline& laststatus&
endfunc
+func Test_cmdwin_temp_curwin()
+ func CheckWraps(expect_wrap)
+ setlocal textwidth=0 wrapmargin=1
+
+ call deletebufline('', 1, '$')
+ let as = repeat('a', winwidth(0) - 2 - &wrapmargin)
+ call setline(1, as .. ' b')
+ normal! gww
+
+ setlocal textwidth& wrapmargin&
+ call assert_equal(a:expect_wrap ? [as, 'b'] : [as .. ' b'], getline(1, '$'))
+ endfunc
+
+ func CheckCmdWin()
+ call assert_equal('command', win_gettype())
+ " textoff and &wrapmargin formatting considers the cmdwin_type char.
+ call assert_equal(1, getwininfo(win_getid())[0].textoff)
+ call CheckWraps(1)
+ endfunc
+
+ func CheckOtherWin()
+ call assert_equal('', win_gettype())
+ call assert_equal(0, getwininfo(win_getid())[0].textoff)
+ call CheckWraps(0)
+ endfunc
+
+ call feedkeys("q::call CheckCmdWin()\<CR>:call win_execute(win_getid(winnr('#')), 'call CheckOtherWin()')\<CR>:q<CR>", 'ntx')
+
+ %bwipe!
+ delfunc CheckWraps
+ delfunc CheckCmdWin
+ delfunc CheckOtherWin
+endfunc
+
+func Test_cmdwin_interrupted()
+ func CheckInterrupted()
+ call feedkeys("q::call assert_equal('', getcmdwintype())\<CR>:call assert_equal('', getcmdtype())\<CR>:q<CR>", 'ntx')
+ endfunc
+
+ augroup CmdWin
+
+ " While opening the cmdwin's split:
+ " Close the cmdwin's window.
+ au WinEnter * ++once quit
+ call CheckInterrupted()
+
+ " Close the old window.
+ au WinEnter * ++once execute winnr('#') 'quit'
+ call CheckInterrupted()
+
+ " Switch back to the old window.
+ au WinEnter * ++once wincmd p
+ call CheckInterrupted()
+
+ " Change the old window's buffer.
+ au WinEnter * ++once call win_execute(win_getid(winnr('#')), 'enew')
+ call CheckInterrupted()
+
+ " Using BufLeave autocmds as cmdwin restrictions do not apply to them when
+ " fired from opening the cmdwin...
+ " After opening the cmdwin's split, while creating the cmdwin's buffer:
+ " Delete the cmdwin's buffer.
+ au BufLeave * ++once bwipe
+ call CheckInterrupted()
+
+ " Close the cmdwin's window.
+ au BufLeave * ++once quit
+ call CheckInterrupted()
+
+ " Close the old window.
+ au BufLeave * ++once execute winnr('#') 'quit'
+ call CheckInterrupted()
+
+ " Switch to a different window.
+ au BufLeave * ++once split
+ call CheckInterrupted()
+
+ " Change the old window's buffer.
+ au BufLeave * ++once call win_execute(win_getid(winnr('#')), 'enew')
+ call CheckInterrupted()
+
+ " However, changing the current buffer is OK and does not interrupt.
+ au BufLeave * ++once edit other
+ call feedkeys("q::let t=getcmdwintype()\<CR>:let b=bufnr()\<CR>:clo<CR>", 'ntx')
+ call assert_equal(':', t)
+ call assert_equal(1, bufloaded('other'))
+ call assert_notequal(b, bufnr('other'))
+
+ augroup END
+
+ " No autocmds should remain, but clear the augroup to be sure.
+ augroup CmdWin
+ au!
+ augroup END
+
+ %bwipe!
+ delfunc CheckInterrupted
+endfunc
+
+func Test_cmdwin_existing_bufname()
+ func CheckName()
+ call assert_equal(1, getbufinfo('')[0].command)
+ call assert_equal(0, getbufinfo('[Command Line]')[0].command)
+ call assert_match('#a\s*"\[Command Line\]"', execute('ls'))
+ call assert_match('%a\s*"\[Command Line\]"', execute('ls'))
+ endfunc
+ file [Command Line]
+ call feedkeys("q::call CheckName()\<CR>:q\<CR>", 'ntx')
+ 0file
+ delfunc CheckName
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_crash.vim b/test/old/testdir/test_crash.vim
index b093b053c5..49e712a901 100644
--- a/test/old/testdir/test_crash.vim
+++ b/test/old/testdir/test_crash.vim
@@ -117,7 +117,7 @@ func Test_crash1_2()
" The following used to crash Vim
let opts = #{cmd: 'sh'}
let vim = GetVimProg()
- let result = 'X_crash1_1_result.txt'
+ let result = 'X_crash1_2_result.txt'
let buf = RunVimInTerminal('sh', opts)
@@ -128,6 +128,38 @@ func Test_crash1_2()
\ ' && echo "crash 1: [OK]" > '.. result .. "\<cr>")
call TermWait(buf, 150)
+ let file = 'crash/poc_win_enter_ext'
+ let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
+ let args = printf(cmn_args, vim, file)
+ call term_sendkeys(buf, args ..
+ \ ' && echo "crash 2: [OK]" >> '.. result .. "\<cr>")
+ call TermWait(buf, 350)
+
+ let file = 'crash/poc_suggest_trie_walk'
+ let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
+ let args = printf(cmn_args, vim, file)
+ call term_sendkeys(buf, args ..
+ \ ' && echo "crash 3: [OK]" >> '.. result .. "\<cr>")
+ call TermWait(buf, 150)
+
+ let file = 'crash/poc_did_set_langmap'
+ let cmn_args = "%s -u NONE -i NONE -n -X -m -n -e -s -S %s -c ':qa!'"
+ let args = printf(cmn_args, vim, file)
+ call term_sendkeys(buf, args ..
+ \ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>")
+ call TermWait(buf, 150)
+
+ let file = 'crash/poc_ex_substitute'
+ let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'"
+ let args = printf(cmn_args, vim, file)
+ " just make sure it runs, we don't care about the resulting echo
+ call term_sendkeys(buf, args .. "\<cr>")
+ " There is no output generated in Github CI for the asan clang build.
+ " so just skip generating the ouput.
+ " call term_sendkeys(buf, args ..
+ " \ ' && echo "crash 5: [OK]" >> '.. result .. "\<cr>")
+ call TermWait(buf, 150)
+
" clean up
exe buf .. "bw!"
@@ -135,6 +167,9 @@ func Test_crash1_2()
let expected = [
\ 'crash 1: [OK]',
+ \ 'crash 2: [OK]',
+ \ 'crash 3: [OK]',
+ \ 'crash 4: [OK]',
\ ]
call assert_equal(expected, getline(1, '$'))
diff --git a/test/old/testdir/test_cursor_func.vim b/test/old/testdir/test_cursor_func.vim
index cf131e8dad..5d99963814 100644
--- a/test/old/testdir/test_cursor_func.vim
+++ b/test/old/testdir/test_cursor_func.vim
@@ -206,6 +206,11 @@ func Test_screenpos()
call assert_equal(#{col: 1, row: 2, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
" nunmenu WinBar.TEST
setlocal winbar&
+ call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
+
+ call assert_equal(#{col: 0, row: 0, endcol: 0, curscol: 0}, screenpos(0, 0, 1))
+ call assert_equal(#{col: 0, row: 0, endcol: 0, curscol: 0}, screenpos(0, -1, 1))
+ call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(0, 1, -v:maxcol))
endfunc
func Test_screenpos_fold()
diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim
index fd94f4a7b2..9a3e006430 100644
--- a/test/old/testdir/test_diffmode.vim
+++ b/test/old/testdir/test_diffmode.vim
@@ -1083,18 +1083,19 @@ endfunc
func Test_diff_with_cursorline_breakindent()
CheckScreendump
- call writefile([
- \ 'hi CursorLine ctermbg=red ctermfg=white',
- \ 'set noequalalways wrap diffopt=followwrap cursorline breakindent',
- \ '50vnew',
- \ 'call setline(1, [" "," "," "," "])',
- \ 'exe "norm 20Afoo\<Esc>j20Afoo\<Esc>j20Afoo\<Esc>j20Abar\<Esc>"',
- \ 'vnew',
- \ 'call setline(1, [" "," "," "," "])',
- \ 'exe "norm 20Abee\<Esc>j20Afoo\<Esc>j20Afoo\<Esc>j20Abaz\<Esc>"',
- \ 'windo diffthis',
- \ '2wincmd w',
- \ ], 'Xtest_diff_cursorline_breakindent', 'D')
+ let lines =<< trim END
+ hi CursorLine ctermbg=red ctermfg=white
+ set noequalalways wrap diffopt=followwrap cursorline breakindent
+ 50vnew
+ call setline(1, [' ', ' ', ' ', ' '])
+ exe "norm! 20Afoo\<Esc>j20Afoo\<Esc>j20Afoo\<Esc>j20Abar\<Esc>"
+ vnew
+ call setline(1, [' ', ' ', ' ', ' '])
+ exe "norm! 20Abee\<Esc>j20Afoo\<Esc>j20Afoo\<Esc>j20Abaz\<Esc>"
+ windo diffthis
+ 2wincmd w
+ END
+ call writefile(lines, 'Xtest_diff_cursorline_breakindent', 'D')
let buf = RunVimInTerminal('-S Xtest_diff_cursorline_breakindent', {})
call term_sendkeys(buf, "gg0")
@@ -1110,11 +1111,30 @@ func Test_diff_with_cursorline_breakindent()
call StopVimInTerminal(buf)
endfunc
+func Test_diff_breakindent_after_filler()
+ CheckScreendump
+
+ let lines =<< trim END
+ set laststatus=0 diffopt+=followwrap breakindent breakindentopt=min:0
+ call setline(1, ['a', ' ' .. repeat('c', 50)])
+ vnew
+ call setline(1, ['a', 'b', ' ' .. repeat('c', 50)])
+ windo diffthis
+ norm! G$
+ END
+ call writefile(lines, 'Xtest_diff_breakindent_after_filler', 'D')
+ let buf = RunVimInTerminal('-S Xtest_diff_breakindent_after_filler', #{rows: 8, cols: 45})
+ call VerifyScreenDump(buf, 'Test_diff_breakindent_after_filler', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_diff_with_syntax()
CheckScreendump
let lines =<< trim END
- void doNothing() {
+ void doNothing() {
int x = 0;
char *s = "hello";
return 5;
@@ -1122,7 +1142,7 @@ func Test_diff_with_syntax()
END
call writefile(lines, 'Xprogram1.c', 'D')
let lines =<< trim END
- void doSomething() {
+ void doSomething() {
int x = 0;
char *s = "there";
return 5;
@@ -1131,7 +1151,7 @@ func Test_diff_with_syntax()
call writefile(lines, 'Xprogram2.c', 'D')
let lines =<< trim END
- edit Xprogram1.c
+ edit Xprogram1.c
diffsplit Xprogram2.c
END
call writefile(lines, 'Xtest_diff_syntax', 'D')
diff --git a/test/old/testdir/test_display.vim b/test/old/testdir/test_display.vim
index bd90287400..70029dcf3c 100644
--- a/test/old/testdir/test_display.vim
+++ b/test/old/testdir/test_display.vim
@@ -253,12 +253,12 @@ func Test_eob_fillchars()
" default value
" call assert_match('eob:\~', &fillchars)
" invalid values
- call assert_fails(':set fillchars=eob:', 'E474:')
- call assert_fails(':set fillchars=eob:xy', 'E474:')
- call assert_fails(':set fillchars=eob:\255', 'E474:')
- call assert_fails(':set fillchars=eob:<ff>', 'E474:')
- call assert_fails(":set fillchars=eob:\x01", 'E474:')
- call assert_fails(':set fillchars=eob:\\x01', 'E474:')
+ call assert_fails(':set fillchars=eob:', 'E1511:')
+ call assert_fails(':set fillchars=eob:xy', 'E1511:')
+ call assert_fails(':set fillchars=eob:\255', 'E1511:')
+ call assert_fails(':set fillchars=eob:<ff>', 'E1511:')
+ call assert_fails(":set fillchars=eob:\x01", 'E1512:')
+ call assert_fails(':set fillchars=eob:\\x01', 'E1512:')
" default is ~
new
redraw
@@ -412,14 +412,16 @@ func Run_Test_display_lastline(euro)
call StopVimInTerminal(buf)
endfunc
-func Test_display_lastline()
+func Test_display_lastline_dump()
CheckScreendump
call Run_Test_display_lastline('')
call Run_Test_display_lastline('euro_')
+endfunc
- call assert_fails(':set fillchars=lastline:', 'E474:')
- call assert_fails(':set fillchars=lastline:〇', 'E474:')
+func Test_display_lastline_fails()
+ call assert_fails(':set fillchars=lastline:', 'E1511:')
+ call assert_fails(':set fillchars=lastline:〇', 'E1512:')
endfunc
func Test_display_long_lastline()
diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim
index 3fe65832c9..67143ab524 100644
--- a/test/old/testdir/test_edit.vim
+++ b/test/old/testdir/test_edit.vim
@@ -2118,5 +2118,39 @@ func Test_edit_overlong_file_name()
bwipe!
endfunc
+func Test_edit_Ctrl_RSB()
+ new
+ let g:triggered = []
+ autocmd InsertCharPre <buffer> let g:triggered += [v:char]
+
+ " i_CTRL-] should not trigger InsertCharPre
+ exe "normal! A\<C-]>"
+ call assert_equal([], g:triggered)
+
+ " i_CTRL-] should expand abbreviations but not trigger InsertCharPre
+ inoreabbr <buffer> f foo
+ exe "normal! Af\<C-]>a"
+ call assert_equal(['f', 'f', 'o', 'o', 'a'], g:triggered)
+ call assert_equal('fooa', getline(1))
+
+ " CTRL-] followed by i_CTRL-V should not expand abbreviations
+ " i_CTRL-V doesn't trigger InsertCharPre
+ call setline(1, '')
+ exe "normal! Af\<C-V>\<C-]>"
+ call assert_equal("f\<C-]>", getline(1))
+
+ let g:triggered = []
+ call setline(1, '')
+
+ " Also test assigning to v:char
+ autocmd InsertCharPre <buffer> let v:char = 'f'
+ exe "normal! Ag\<C-]>h"
+ call assert_equal(['g', 'f', 'o', 'o', 'h'], g:triggered)
+ call assert_equal('ffff', getline(1))
+
+ autocmd! InsertCharPre
+ unlet g:triggered
+ bwipe!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_excmd.vim b/test/old/testdir/test_excmd.vim
index c729ff4929..b7356c22fa 100644
--- a/test/old/testdir/test_excmd.vim
+++ b/test/old/testdir/test_excmd.vim
@@ -90,23 +90,31 @@ endfunc
" Test for the :drop command
func Test_drop_cmd()
- call writefile(['L1', 'L2'], 'Xfile')
+ call writefile(['L1', 'L2'], 'Xdropfile', 'D')
+ " Test for reusing the current buffer
enew | only
- drop Xfile
+ let expected_nr = bufnr()
+ drop Xdropfile
+ call assert_equal(expected_nr, bufnr())
call assert_equal('L2', getline(2))
" Test for switching to an existing window
below new
- drop Xfile
+ drop Xdropfile
call assert_equal(1, winnr())
- " Test for splitting the current window
+ " Test for splitting the current window (set nohidden)
enew | only
set modified
- drop Xfile
+ drop Xdropfile
call assert_equal(2, winnr('$'))
+ " Not splitting the current window even if modified (set hidden)
+ set hidden
+ enew | only
+ set modified
+ drop Xdropfile
+ call assert_equal(1, winnr('$'))
" Check for setting the argument list
- call assert_equal(['Xfile'], argv())
+ call assert_equal(['Xdropfile'], argv())
enew | only!
- call delete('Xfile')
endfunc
" Test for the :append command
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index 87044a06b5..303b1585e2 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -140,6 +140,7 @@ func s:GetFilenameChecks() abort
\ 'chatito': ['file.chatito'],
\ 'chill': ['file..ch'],
\ 'chordpro': ['file.chopro', 'file.crd', 'file.cho', 'file.crdpro', 'file.chordpro'],
+ \ 'chuck': ['file.ck'],
\ 'cl': ['file.eni'],
\ 'clean': ['file.dcl', 'file.icl'],
\ 'clojure': ['file.clj', 'file.cljs', 'file.cljx', 'file.cljc'],
@@ -203,7 +204,7 @@ func s:GetFilenameChecks() abort
\ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe', 'drac.file', 'lpe', 'lvs', 'some-lpe', 'some-lvs'],
\ 'dtd': ['file.dtd'],
\ 'dtrace': ['/usr/lib/dtrace/io.d'],
- \ 'dts': ['file.dts', 'file.dtsi'],
+ \ 'dts': ['file.dts', 'file.dtsi', 'file.dtso', 'file.its'],
\ 'dune': ['jbuild', 'dune', 'dune-project', 'dune-workspace'],
\ 'dylan': ['file.dylan'],
\ 'dylanintr': ['file.intr'],
@@ -226,6 +227,7 @@ func s:GetFilenameChecks() abort
\ 'esqlc': ['file.ec', 'file.EC'],
\ 'esterel': ['file.strl'],
\ 'eterm': ['anyEterm/file.cfg', 'Eterm/file.cfg', 'some-Eterm/file.cfg'],
+ \ 'execline': ['/etc/s6-rc/run', './s6-rc/src/dbus-srv/up', '/sbin/s6-shutdown'],
\ 'exim': ['exim.conf'],
\ 'expect': ['file.exp'],
\ 'exports': ['exports'],
@@ -308,7 +310,7 @@ func s:GetFilenameChecks() abort
\ 'hoon': ['file.hoon'],
\ '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'],
+ \ 'html': ['file.html', 'file.htm', 'file.cshtml', 'file.component.html'],
\ 'htmlm4': ['file.html.m4'],
\ 'httest': ['file.htt', 'file.htb'],
\ 'hurl': ['file.hurl'],
@@ -339,13 +341,13 @@ func s:GetFilenameChecks() abort
\ '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', '.prettierrc', '.firebaserc', '.stylelintrc', 'file.slnf'],
\ 'json5': ['file.json5'],
- \ 'jsonc': ['file.jsonc', '.babelrc', '.eslintrc', '.jsfmtrc', '.jshintrc', '.hintrc', '.swrc', 'jsconfig.json', 'tsconfig.json', 'tsconfig.test.json', 'tsconfig-test.json'],
+ \ 'jsonc': ['file.jsonc', '.babelrc', '.eslintrc', '.jsfmtrc', '.jshintrc', '.hintrc', '.swrc', 'jsconfig.json', 'tsconfig.json', 'tsconfig.test.json', 'tsconfig-test.json', '.luaurc'],
\ 'jsonl': ['file.jsonl'],
\ 'jsonnet': ['file.jsonnet', 'file.libsonnet'],
\ 'jsp': ['file.jsp'],
\ 'julia': ['file.jl'],
\ 'just': ['justfile', 'Justfile', '.justfile', 'config.just'],
- \ 'kconfig': ['Kconfig', 'Kconfig.debug', 'Kconfig.file'],
+ \ 'kconfig': ['Kconfig', 'Kconfig.debug', 'Kconfig.file', 'Config.in', 'Config.in.host'],
\ 'kdl': ['file.kdl'],
\ 'kivy': ['file.kv'],
\ 'kix': ['file.kix'],
@@ -423,7 +425,6 @@ func s:GetFilenameChecks() abort
\ 'mma': ['file.nb'],
\ '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'],
- \ 'modula2': ['file.m2', 'file.mi'],
\ 'modula3': ['file.m3', 'file.mg', 'file.i3', 'file.ig', 'file.lm3'],
\ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'],
\ 'moo': ['file.moo'],
@@ -437,6 +438,7 @@ func s:GetFilenameChecks() abort
\ 'mojo': ['file.mojo', 'file.🔥'],
\ 'mupad': ['file.mu'],
\ 'mush': ['file.mush'],
+ \ 'mustache': ['file.mustache'],
\ 'muttrc': ['Muttngrc', 'Muttrc', '.muttngrc', '.muttngrc-file', '.muttrc', '.muttrc-file', '/.mutt/muttngrc', '/.mutt/muttngrc-file', '/.mutt/muttrc', '/.mutt/muttrc-file', '/.muttng/muttngrc', '/.muttng/muttngrc-file', '/.muttng/muttrc', '/.muttng/muttrc-file', '/etc/Muttrc.d/file', '/etc/Muttrc.d/file.rc', 'Muttngrc-file', 'Muttrc-file', 'any/.mutt/muttngrc', 'any/.mutt/muttngrc-file', 'any/.mutt/muttrc', 'any/.mutt/muttrc-file', 'any/.muttng/muttngrc', 'any/.muttng/muttngrc-file', 'any/.muttng/muttrc', 'any/.muttng/muttrc-file', 'any/etc/Muttrc.d/file', 'muttngrc', 'muttngrc-file', 'muttrc', 'muttrc-file'],
\ 'mysql': ['file.mysql'],
\ 'n1ql': ['file.n1ql', 'file.nql'],
@@ -470,6 +472,7 @@ func s:GetFilenameChecks() abort
\ 'opl': ['file.OPL', 'file.OPl', 'file.OpL', 'file.Opl', 'file.oPL', 'file.oPl', 'file.opL', 'file.opl'],
\ 'ora': ['file.ora'],
\ 'org': ['file.org', 'file.org_archive'],
+ \ 'pacmanlog': ['pacman.log'],
\ 'pamconf': ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf', 'any/etc/pam.d/file'],
\ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment', '.pam_environment', 'pam_env.conf'],
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
@@ -578,7 +581,7 @@ func s:GetFilenameChecks() abort
\ 'services': ['/etc/services', 'any/etc/services'],
\ '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', '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh', '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf'],
+ \ 'sh': ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh', '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats'],
\ 'sieve': ['file.siv', 'file.sieve'],
\ 'sil': ['file.sil'],
\ 'simula': ['file.sim'],
@@ -826,6 +829,7 @@ let s:script_checks = {
\ ['#!/path/itclsh'],
\ ['#!/path/itkwish']],
\ 'expect': [['#!/path/expect']],
+ \ 'execline': [['#!/sbin/execlineb -S0'], ['#!/usr/bin/execlineb']],
\ 'gnuplot': [['#!/path/gnuplot']],
\ 'make': [['#!/path/make']],
\ 'nix': [['#!/path/nix-shell']],
@@ -877,6 +881,7 @@ let s:script_env_checks = {
\ 'perl': [['#!/usr/bin/env VAR=val perl']],
\ 'scala': [['#!/usr/bin/env VAR=val VVAR=vval scala']],
\ 'awk': [['#!/usr/bin/env VAR=val -i awk']],
+ \ 'execline': [['#!/usr/bin/env execlineb']],
\ 'scheme': [['#!/usr/bin/env VAR=val --ignore-environment scheme']],
\ 'python': [['#!/usr/bin/env VAR=val -S python -w -T']],
\ 'wml': [['#!/usr/bin/env VAR=val --split-string wml']],
@@ -1506,79 +1511,89 @@ func Test_mod_file()
filetype on
" *.mod defaults to Modsim III
- call writefile(['locks like Modsim III'], 'modfile.mod')
- split modfile.mod
+ call writefile(['locks like Modsim III'], 'Xfile.mod', 'D')
+ split Xfile.mod
call assert_equal('modsim3', &filetype)
bwipe!
" Users preference set by g:filetype_mod
let g:filetype_mod = 'lprolog'
- split modfile.mod
+ split Xfile.mod
call assert_equal('lprolog', &filetype)
unlet g:filetype_mod
bwipe!
+ " LambdaProlog module
+ call writefile(['module lpromod.'], 'Xfile.mod')
+ split Xfile.mod
+ call assert_equal('lprolog', &filetype)
+ bwipe!
+
+ " LambdaProlog with comment and empty lines prior module
+ call writefile(['', '% with', '% comment', '', 'module lpromod.'], 'Xfile.mod')
+ split Xfile.mod
+ call assert_equal('lprolog', &filetype)
+ bwipe!
+
" RAPID header start with a line containing only "%%%",
" but is not always present.
- call writefile(['%%%'], 'modfile.mod')
- split modfile.mod
+ call writefile(['%%%'], 'Xfile.mod')
+ split Xfile.mod
call assert_equal('rapid', &filetype)
bwipe!
- call delete('modfile.mod')
" RAPID supports umlauts in module names, leading spaces,
" the .mod extension is not case sensitive.
- call writefile([' module ÜmlautModule'], 'modfile.Mod')
- split modfile.Mod
+ call writefile([' module ÜmlautModule'], 'Xfile.Mod', 'D')
+ split Xfile.Mod
call assert_equal('rapid', &filetype)
bwipe!
- call delete('modfile.Mod')
" RAPID is not case sensitive, embedded spaces, sysmodule,
" file starts with empty line(s).
- call writefile(['', 'MODULE rapidmödüle (SYSMODULE,NOSTEPIN)'], 'modfile.MOD')
- split modfile.MOD
+ call writefile(['', 'MODULE rapidmödüle (SYSMODULE,NOSTEPIN)'], 'Xfile.MOD', 'D')
+ split Xfile.MOD
call assert_equal('rapid', &filetype)
bwipe!
" Modula-2 MODULE not start of line
- call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'modfile.MOD')
- split modfile.MOD
+ call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'Xfile.mod')
+ split Xfile.mod
call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
bwipe!
" Modula-2 with comment and empty lines prior MODULE
- call writefile(['', '(* with', ' comment *)', '', 'MODULE Module2Mod;'], 'modfile.MOD')
- split modfile.MOD
+ call writefile(['', '(* with', ' comment *)', '', 'MODULE Module2Mod;'], 'Xfile.mod')
+ split Xfile.mod
call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
bwipe!
- call delete('modfile.MOD')
- " LambdaProlog module
- call writefile(['module lpromod.'], 'modfile.mod')
- split modfile.mod
- call assert_equal('lprolog', &filetype)
+ " Modula-2 program MODULE with priorty (and uppercase extension)
+ call writefile(['MODULE Module2Mod [42];'], 'Xfile.MOD')
+ split Xfile.MOD
+ call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
bwipe!
- " LambdaProlog with comment and empty lines prior module
- call writefile(['', '% with', '% comment', '', 'module lpromod.'], 'modfile.mod')
- split modfile.mod
- call assert_equal('lprolog', &filetype)
+ " Modula-2 implementation MODULE with priorty (and uppercase extension)
+ call writefile(['IMPLEMENTATION MODULE Module2Mod [42];'], 'Xfile.MOD')
+ split Xfile.MOD
+ call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
bwipe!
- call delete('modfile.mod')
" go.mod
- call writefile(['module example.com/M'], 'go.mod')
+ call writefile(['module example.com/M'], 'go.mod', 'D')
split go.mod
call assert_equal('gomod', &filetype)
bwipe!
- call delete('go.mod')
call writefile(['module M'], 'go.mod')
split go.mod
call assert_equal('gomod', &filetype)
bwipe!
- call delete('go.mod')
filetype off
endfunc
@@ -2279,4 +2294,38 @@ func Test_i_file()
filetype off
endfunc
+func Test_def_file()
+ filetype on
+
+ call writefile(['this is the fallback'], 'Xfile.def', 'D')
+ split Xfile.def
+ call assert_equal('def', &filetype)
+ bwipe!
+
+ " Test dist#ft#FTdef()
+
+ let g:filetype_def = 'modula2'
+ split Xfile.def
+ call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
+ bwipe!
+ unlet g:filetype_def
+
+ " Modula-2
+
+ call writefile(['(* a Modula-2 comment *)'], 'Xfile.def')
+ split Xfile.def
+ call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
+ bwipe!
+
+ call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'Xfile.def')
+ split Xfile.def
+ call assert_equal('modula2', &filetype)
+ call assert_equal('pim', b:modula2.dialect)
+ bwipe!
+
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_filter_map.vim b/test/old/testdir/test_filter_map.vim
index 7658797759..5ef56c5623 100644
--- a/test/old/testdir/test_filter_map.vim
+++ b/test/old/testdir/test_filter_map.vim
@@ -14,6 +14,18 @@ func Test_filter_map_list_expr_string()
call assert_equal([0, 2, 4, 6], map([1, 2, 3, 4], 'v:key * 2'))
call assert_equal([9, 9, 9, 9], map([1, 2, 3, 4], 9))
call assert_equal([7, 7, 7], map([1, 2, 3], ' 7 '))
+
+ " foreach()
+ let list01 = [1, 2, 3, 4]
+ let list02 = []
+ call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(list02, v:val * 2)'))
+ call assert_equal([2, 4, 6, 8], list02)
+ let list02 = []
+ call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(list02, v:key * 2)'))
+ call assert_equal([0, 2, 4, 6], list02)
+ let list02 = []
+ call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(list02, 9)'))
+ call assert_equal([9, 9, 9, 9], list02)
endfunc
" dict with expression string
@@ -29,6 +41,14 @@ func Test_filter_map_dict_expr_string()
call assert_equal({"foo": 2, "bar": 4, "baz": 6}, map(copy(dict), 'v:val * 2'))
call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, map(copy(dict), 'v:key[0]'))
call assert_equal({"foo": 9, "bar": 9, "baz": 9}, map(copy(dict), 9))
+
+ " foreach()
+ let dict01 = {}
+ call assert_equal(dict, foreach(copy(dict), 'let dict01[v:key] = v:val * 2'))
+ call assert_equal({"foo": 2, "bar": 4, "baz": 6}, dict01)
+ let dict01 = {}
+ call assert_equal(dict, foreach(copy(dict), 'let dict01[v:key] = v:key[0]'))
+ call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, dict01)
endfunc
" list with funcref
@@ -54,6 +74,25 @@ func Test_filter_map_list_expr_funcref()
return a:index * 2
endfunc
call assert_equal([0, 2, 4, 6], map([1, 2, 3, 4], function('s:filter4')))
+
+ " foreach()
+ func! s:foreach1(index, val) abort
+ call add(g:test_variable, a:val + 1)
+ return [ 11, 12, 13, 14 ]
+ endfunc
+ let g:test_variable = []
+ call assert_equal([0, 1, 2, 3, 4], foreach(range(5), function('s:foreach1')))
+ call assert_equal([1, 2, 3, 4, 5], g:test_variable)
+ call remove(g:, 'test_variable')
+endfunc
+
+func Test_filter_map_nested()
+ let x = {"x":10}
+ let r = map(range(2), 'filter(copy(x), "1")')
+ call assert_equal([x, x], r)
+
+ let r = map(copy(x), 'filter(copy(x), "1")')
+ call assert_equal({"x": x}, r)
endfunc
" dict with funcref
@@ -81,11 +120,46 @@ func Test_filter_map_dict_expr_funcref()
return a:key[0]
endfunc
call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, map(copy(dict), function('s:filter4')))
+
+ " foreach()
+ func! s:foreach1(key, val) abort
+ call extend(g:test_variable, {a:key: a:val * 2})
+ return [ 11, 12, 13, 14 ]
+ endfunc
+ let g:test_variable = {}
+ call assert_equal(dict, foreach(copy(dict), function('s:foreach1')))
+ call assert_equal({"foo": 2, "bar": 4, "baz": 6}, g:test_variable)
+ call remove(g:, 'test_variable')
+endfunc
+
+func Test_map_filter_locked()
+ let list01 = [1, 2, 3, 4]
+ lockvar 1 list01
+ call assert_fails('call filter(list01, "v:val > 1")', 'E741:')
+ call assert_equal([2, 4, 6, 8], map(list01, 'v:val * 2'))
+ call assert_equal([1, 2, 3, 4], map(list01, 'v:val / 2'))
+ call assert_equal([2, 4, 6, 8], mapnew(list01, 'v:val * 2'))
+ let g:test_variable = []
+ call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(g:test_variable, v:val * 2)'))
+ call remove(g:, 'test_variable')
+ call assert_fails('call filter(list01, "v:val > 1")', 'E741:')
+ unlockvar 1 list01
+ lockvar! list01
+ call assert_fails('call filter(list01, "v:val > 1")', 'E741:')
+ call assert_fails('call map(list01, "v:val * 2")', 'E741:')
+ call assert_equal([2, 4, 6, 8], mapnew(list01, 'v:val * 2'))
+ let g:test_variable = []
+ call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(g:test_variable, v:val * 2)'))
+ call assert_fails('call foreach(list01, "let list01[0] = -1")', 'E741:')
+ call assert_fails('call filter(list01, "v:val > 1")', 'E741:')
+ call remove(g:, 'test_variable')
+ unlockvar! list01
endfunc
func Test_map_filter_fails()
call assert_fails('call map([1], "42 +")', 'E15:')
call assert_fails('call filter([1], "42 +")', 'E15:')
+ call assert_fails('call foreach([1], "let a = }")', 'E15:')
call assert_fails("let l = filter([1, 2, 3], '{}')", 'E728:')
call assert_fails("let l = filter({'k' : 10}, '{}')", 'E728:')
call assert_fails("let l = filter([1, 2], {})", 'E731:')
@@ -99,6 +173,8 @@ func Test_map_filter_fails()
" Nvim doesn't have null partials
" call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial()))
call assert_fails("let l = filter([1, 2], {a, b, c -> 1})", 'E119:')
+ call assert_fails('call foreach([1], "xyzzy")', 'E492:')
+ call assert_fails('call foreach([1], "let a = foo")', 'E121:')
endfunc
func Test_map_and_modify()
@@ -116,7 +192,7 @@ endfunc
func Test_filter_and_modify()
let l = [0]
- " cannot change the list halfway a map()
+ " cannot change the list halfway thru filter()
call assert_fails('call filter(l, "remove(l, 0)")', 'E741:')
let d = #{a: 0, b: 0, c: 0}
@@ -126,6 +202,18 @@ func Test_filter_and_modify()
call assert_fails('call filter(b, "remove(b, 0)")', 'E741:')
endfunc
+func Test_foreach_and_modify()
+ let l = [0]
+ " cannot change the list halfway thru foreach()
+ call assert_fails('call foreach(l, "let a = remove(l, 0)")', 'E741:')
+
+ let d = #{a: 0, b: 0, c: 0}
+ call assert_fails('call foreach(d, "let a = remove(d, v:key)")', 'E741:')
+
+ let b = 0z1234
+ call assert_fails('call foreach(b, "let a = remove(b, 0)")', 'E741:')
+endfunc
+
func Test_mapnew_dict()
let din = #{one: 1, two: 2}
let dout = mapnew(din, {k, v -> string(v)})
@@ -153,6 +241,36 @@ func Test_mapnew_blob()
call assert_equal(0z129956, bout)
endfunc
+func Test_foreach_blob()
+ let lines =<< trim END
+ LET g:test_variable = []
+ call assert_equal(0z0001020304, foreach(0z0001020304, 'call add(g:test_variable, v:val)'))
+ call assert_equal([0, 1, 2, 3, 4], g:test_variable)
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ func! s:foreach1(index, val) abort
+ call add(g:test_variable, a:val)
+ return [ 11, 12, 13, 14 ]
+ endfunc
+ let g:test_variable = []
+ call assert_equal(0z0001020304, foreach(0z0001020304, function('s:foreach1')))
+ call assert_equal([0, 1, 2, 3, 4], g:test_variable)
+
+ let lines =<< trim END
+ def Foreach1(_, val: any): list<number>
+ add(g:test_variable, val)
+ return [ 11, 12, 13, 14 ]
+ enddef
+ g:test_variable = []
+ assert_equal(0z0001020304, foreach(0z0001020304, Foreach1))
+ assert_equal([0, 1, 2, 3, 4], g:test_variable)
+ END
+ call CheckDefSuccess(lines)
+
+ call remove(g:, 'test_variable')
+endfunc
+
" Test for using map(), filter() and mapnew() with a string
func Test_filter_map_string()
" filter()
@@ -212,6 +330,37 @@ func Test_filter_map_string()
END
call CheckLegacyAndVim9Success(lines)
+ " foreach()
+ let lines =<< trim END
+ VAR s = "abc"
+ LET g:test_variable = []
+ call assert_equal(s, foreach(s, 'call add(g:test_variable, v:val)'))
+ call assert_equal(['a', 'b', 'c'], g:test_variable)
+ LET g:test_variable = []
+ LET s = 'ã‚iã†ãˆãŠ'
+ call assert_equal(s, foreach(s, 'call add(g:test_variable, v:val)'))
+ call assert_equal(['ã‚', 'i', 'ã†', 'ãˆ', 'ãŠ'], g:test_variable)
+ END
+ call CheckLegacyAndVim9Success(lines)
+ func! s:foreach1(index, val) abort
+ call add(g:test_variable, a:val)
+ return [ 11, 12, 13, 14 ]
+ endfunc
+ let g:test_variable = []
+ call assert_equal('abcd', foreach('abcd', function('s:foreach1')))
+ call assert_equal(['a', 'b', 'c', 'd'], g:test_variable)
+ let lines =<< trim END
+ def Foreach1(_, val: string): list<number>
+ add(g:test_variable, val)
+ return [ 11, 12, 13, 14 ]
+ enddef
+ g:test_variable = []
+ assert_equal('abcd', foreach('abcd', Foreach1))
+ assert_equal(['a', 'b', 'c', 'd'], g:test_variable)
+ END
+ call CheckDefSuccess(lines)
+ call remove(g:, 'test_variable')
+
let lines =<< trim END
#" map() and filter()
call assert_equal('[ã‚][âˆ][a][😊][â‰][💕][💕][b][💕]', map(filter('ã‚xâˆax😊xâ‰ðŸ’•💕b💕x', '"x" != v:val'), '"[" .. v:val .. "]"'))
diff --git a/test/old/testdir/test_fold.vim b/test/old/testdir/test_fold.vim
index e529a94174..eae6952e72 100644
--- a/test/old/testdir/test_fold.vim
+++ b/test/old/testdir/test_fold.vim
@@ -1578,4 +1578,17 @@ func Test_foldexpr_return_empty_string()
bwipe!
endfunc
+" Make sure that when ending a fold that hasn't been started, it does not
+" start a new fold.
+func Test_foldexpr_end_fold()
+ new
+ setlocal foldmethod=expr
+ let &l:foldexpr = 'v:lnum == 2 ? "<2" : "="'
+ call setline(1, range(1, 3))
+ redraw
+ call assert_equal([0, 0, 0], range(1, 3)->map('foldlevel(v:val)'))
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index 88a29968fe..3f9ac94782 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -1044,6 +1044,192 @@ func Test_matchstrpos()
call assert_equal(['', -1, -1], matchstrpos(v:_null_list, '\a'))
endfunc
+" Test for matchstrlist()
+func Test_matchstrlist()
+ let lines =<< trim END
+ #" Basic match
+ call assert_equal([{'idx': 0, 'byteidx': 1, 'text': 'bout'},
+ \ {'idx': 1, 'byteidx': 1, 'text': 'bove'}],
+ \ matchstrlist(['about', 'above'], 'bo.*'))
+ #" no match
+ call assert_equal([], matchstrlist(['about', 'above'], 'xy.*'))
+ #" empty string
+ call assert_equal([], matchstrlist([''], '.'))
+ #" empty pattern
+ call assert_equal([{'idx': 0, 'byteidx': 0, 'text': ''}], matchstrlist(['abc'], ''))
+ #" method call
+ call assert_equal([{'idx': 0, 'byteidx': 2, 'text': 'it'}], ['editor']->matchstrlist('ed\zsit\zeor'))
+ #" single character matches
+ call assert_equal([{'idx': 0, 'byteidx': 5, 'text': 'r'}],
+ \ ['editor']->matchstrlist('r'))
+ call assert_equal([{'idx': 0, 'byteidx': 0, 'text': 'a'}], ['a']->matchstrlist('a'))
+ call assert_equal([{'idx': 0, 'byteidx': 0, 'text': ''}],
+ \ matchstrlist(['foobar'], '\zs'))
+ #" string with tabs
+ call assert_equal([{'idx': 0, 'byteidx': 1, 'text': 'foo'}],
+ \ matchstrlist(["\tfoobar"], 'foo'))
+ #" string with multibyte characters
+ call assert_equal([{'idx': 0, 'byteidx': 2, 'text': '😊😊'}],
+ \ matchstrlist(["\t\t😊😊"], '\k\+'))
+
+ #" null string
+ call assert_equal([], matchstrlist(v:_null_list, 'abc'))
+ call assert_equal([], matchstrlist([v:_null_string], 'abc'))
+ call assert_equal([{'idx': 0, 'byteidx': 0, 'text': ''}],
+ \ matchstrlist(['abc'], v:_null_string))
+
+ #" sub matches
+ call assert_equal([{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}], matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', {'submatches': v:true}))
+
+ #" null dict argument
+ call assert_equal([{'idx': 0, 'byteidx': 0, 'text': 'vim'}],
+ \ matchstrlist(['vim'], '\w\+', v:_null_dict))
+
+ #" Error cases
+ call assert_fails("echo matchstrlist('abc', 'a')", 'E1211: List required for argument 1')
+ call assert_fails("echo matchstrlist(['abc'], {})", 'E1174: String required for argument 2')
+ call assert_fails("echo matchstrlist(['abc'], '.', [])", 'E1206: Dictionary required for argument 3')
+ call assert_fails("echo matchstrlist(['abc'], 'a', {'submatches': []})", 'E475: Invalid value for argument submatches')
+ call assert_fails("echo matchstrlist(['abc'], '\\@=')", 'E866: (NFA regexp) Misplaced @')
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ let lines =<< trim END
+ vim9script
+ # non string items
+ matchstrlist([0z10, {'a': 'x'}], 'x')
+ END
+ call CheckSourceSuccess(lines)
+
+ let lines =<< trim END
+ vim9script
+ def Foo()
+ # non string items
+ assert_equal([], matchstrlist([0z10, {'a': 'x'}], 'x'))
+ enddef
+ Foo()
+ END
+ call CheckSourceFailure(lines, 'E1013: Argument 1: type mismatch, expected list<string> but got list<any>', 2)
+endfunc
+
+" Test for matchbufline()
+func Test_matchbufline()
+ let lines =<< trim END
+ #" Basic match
+ new
+ call setline(1, ['about', 'above', 'below'])
+ VAR bnr = bufnr()
+ wincmd w
+ call assert_equal([{'lnum': 1, 'byteidx': 1, 'text': 'bout'},
+ \ {'lnum': 2, 'byteidx': 1, 'text': 'bove'}],
+ \ matchbufline(bnr, 'bo.*', 1, '$'))
+ #" multiple matches in a line
+ call setbufline(bnr, 1, ['about about', 'above above', 'below'])
+ call assert_equal([{'lnum': 1, 'byteidx': 1, 'text': 'bout'},
+ \ {'lnum': 1, 'byteidx': 7, 'text': 'bout'},
+ \ {'lnum': 2, 'byteidx': 1, 'text': 'bove'},
+ \ {'lnum': 2, 'byteidx': 7, 'text': 'bove'}],
+ \ matchbufline(bnr, 'bo\k\+', 1, '$'))
+ #" no match
+ call assert_equal([], matchbufline(bnr, 'xy.*', 1, '$'))
+ #" match on a particular line
+ call assert_equal([{'lnum': 2, 'byteidx': 7, 'text': 'bove'}],
+ \ matchbufline(bnr, 'bo\k\+$', 2, 2))
+ #" match on a particular line
+ call assert_equal([], matchbufline(bnr, 'bo.*', 3, 3))
+ #" empty string
+ call deletebufline(bnr, 1, '$')
+ call assert_equal([], matchbufline(bnr, '.', 1, '$'))
+ #" empty pattern
+ call setbufline(bnr, 1, 'abc')
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': ''}],
+ \ matchbufline(bnr, '', 1, '$'))
+ #" method call
+ call setbufline(bnr, 1, 'editor')
+ call assert_equal([{'lnum': 1, 'byteidx': 2, 'text': 'it'}],
+ \ bnr->matchbufline('ed\zsit\zeor', 1, 1))
+ #" single character matches
+ call assert_equal([{'lnum': 1, 'byteidx': 5, 'text': 'r'}],
+ \ matchbufline(bnr, 'r', 1, '$'))
+ call setbufline(bnr, 1, 'a')
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'a'}],
+ \ matchbufline(bnr, 'a', 1, '$'))
+ #" zero-width match
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': ''}],
+ \ matchbufline(bnr, '\zs', 1, '$'))
+ #" string with tabs
+ call setbufline(bnr, 1, "\tfoobar")
+ call assert_equal([{'lnum': 1, 'byteidx': 1, 'text': 'foo'}],
+ \ matchbufline(bnr, 'foo', 1, '$'))
+ #" string with multibyte characters
+ call setbufline(bnr, 1, "\t\t😊😊")
+ call assert_equal([{'lnum': 1, 'byteidx': 2, 'text': '😊😊'}],
+ \ matchbufline(bnr, '\k\+', 1, '$'))
+ #" empty buffer
+ call deletebufline(bnr, 1, '$')
+ call assert_equal([], matchbufline(bnr, 'abc', 1, '$'))
+
+ #" Non existing buffer
+ call setbufline(bnr, 1, 'abc')
+ call assert_fails("echo matchbufline(5000, 'abc', 1, 1)", 'E158: Invalid buffer name: 5000')
+ #" null string
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': ''}],
+ \ matchbufline(bnr, v:_null_string, 1, 1))
+ #" invalid starting line number
+ call assert_equal([], matchbufline(bnr, 'abc', 100, 100))
+ #" ending line number greater than the last line
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'abc'}],
+ \ matchbufline(bnr, 'abc', 1, 100))
+ #" ending line number greater than the starting line number
+ call setbufline(bnr, 1, ['one', 'two'])
+ call assert_fails($"echo matchbufline({bnr}, 'abc', 2, 1)", 'E475: Invalid value for argument end_lnum')
+
+ #" sub matches
+ call deletebufline(bnr, 1, '$')
+ call setbufline(bnr, 1, 'acd')
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}],
+ \ matchbufline(bnr, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 1, '$', {'submatches': v:true}))
+
+ #" null dict argument
+ call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'acd'}],
+ \ matchbufline(bnr, '\w\+', '$', '$', v:_null_dict))
+
+ #" Error cases
+ call assert_fails("echo matchbufline([1], 'abc', 1, 1)", 'E1220: String or Number required for argument 1')
+ call assert_fails("echo matchbufline(1, {}, 1, 1)", 'E1174: String required for argument 2')
+ call assert_fails("echo matchbufline(1, 'abc', {}, 1)", 'E1220: String or Number required for argument 3')
+ call assert_fails("echo matchbufline(1, 'abc', 1, {})", 'E1220: String or Number required for argument 4')
+ call assert_fails($"echo matchbufline({bnr}, 'abc', -1, '$')", 'E475: Invalid value for argument lnum')
+ call assert_fails($"echo matchbufline({bnr}, 'abc', 1, -1)", 'E475: Invalid value for argument end_lnum')
+ call assert_fails($"echo matchbufline({bnr}, '\\@=', 1, 1)", 'E866: (NFA regexp) Misplaced @')
+ call assert_fails($"echo matchbufline({bnr}, 'abc', 1, 1, {{'submatches': []}})", 'E475: Invalid value for argument submatches')
+ :%bdelete!
+ call assert_fails($"echo matchbufline({bnr}, 'abc', 1, '$'))", 'E681: Buffer is not loaded')
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ call assert_fails($"echo matchbufline('', 'abc', 'abc', 1)", 'E475: Invalid value for argument lnum')
+ call assert_fails($"echo matchbufline('', 'abc', 1, 'abc')", 'E475: Invalid value for argument end_lnum')
+
+ let lines =<< trim END
+ vim9script
+ def Foo()
+ echo matchbufline('', 'abc', 'abc', 1)
+ enddef
+ Foo()
+ END
+ call CheckSourceFailure(lines, 'E1030: Using a String as a Number: "abc"', 1)
+
+ let lines =<< trim END
+ vim9script
+ def Foo()
+ echo matchbufline('', 'abc', 1, 'abc')
+ enddef
+ Foo()
+ END
+ call CheckSourceFailure(lines, 'E1030: Using a String as a Number: "abc"', 1)
+endfunc
+
func Test_nextnonblank_prevnonblank()
new
insert
@@ -2485,6 +2671,10 @@ func Test_readdir()
let files = readdir('Xdir', {x -> len(add(l, x)) == 2 ? -1 : 1})
call assert_equal(1, len(files))
+ " Nested readdir() must not crash
+ let files = readdir('Xdir', 'readdir("Xdir", "1") != []')
+ call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
+
eval 'Xdir'->delete('rf')
endfunc
diff --git a/test/old/testdir/test_getvar.vim b/test/old/testdir/test_getvar.vim
index 331f3cfe8a..1e29f49fb4 100644
--- a/test/old/testdir/test_getvar.vim
+++ b/test/old/testdir/test_getvar.vim
@@ -83,6 +83,7 @@ func Test_var()
unlet def_dict
+ call assert_equal("", gettabwinvar(9, 2020, ''))
call assert_equal('', gettabwinvar(2, 3, '&nux'))
call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
tabonly
diff --git a/test/old/testdir/test_goto.vim b/test/old/testdir/test_goto.vim
index 6d029ffda2..c5492ff97b 100644
--- a/test/old/testdir/test_goto.vim
+++ b/test/old/testdir/test_goto.vim
@@ -313,18 +313,23 @@ func Test_gd_string_only()
call XTest_goto_decl('gd', lines, 5, 10)
endfunc
-" Check that setting 'cursorline' does not change curswant
-func Test_cursorline_keep_col()
+" Check that setting some options does not change curswant
+func Test_set_options_keep_col()
new
call setline(1, ['long long long line', 'short line'])
normal ggfi
let pos = getcurpos()
normal j
- set cursorline
+ set invhlsearch spell spelllang=en,cjk spelloptions=camel textwidth=80
+ set cursorline cursorcolumn cursorlineopt=line colorcolumn=+1
+ set background=dark
+ set background=light
normal k
call assert_equal(pos, getcurpos())
bwipe!
- set nocursorline
+ set hlsearch& spell& spelllang& spelloptions& textwidth&
+ set cursorline& cursorcolumn& cursorlineopt& colorcolumn&
+ set background&
endfunc
func Test_gd_local_block()
diff --git a/test/old/testdir/test_highlight.vim b/test/old/testdir/test_highlight.vim
index a83dc34063..bcaa1dac5d 100644
--- a/test/old/testdir/test_highlight.vim
+++ b/test/old/testdir/test_highlight.vim
@@ -541,7 +541,7 @@ func Test_cursorline_after_yank()
call writefile([
\ 'set cul rnu',
\ 'call setline(1, ["","1","2","3",""])',
- \ ], 'Xtest_cursorline_yank')
+ \ ], 'Xtest_cursorline_yank', 'D')
let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8})
call TermWait(buf)
call term_sendkeys(buf, "Gy3k")
@@ -552,25 +552,25 @@ func Test_cursorline_after_yank()
" clean up
call StopVimInTerminal(buf)
- call delete('Xtest_cursorline_yank')
endfunc
-" test for issue https://github.com/vim/vim/issues/4862
+" Test for issue #4862: pasting above 'cursorline' redraws properly.
func Test_put_before_cursorline()
new
only!
- call setline(1, 'A')
+ call setline(1, ['A', 'B', 'C'])
+ call cursor(2, 1)
redraw
- let std_attr = screenattr(1, 1)
+ let std_attr = screenattr(2, 1)
set cursorline
redraw
- let cul_attr = screenattr(1, 1)
+ let cul_attr = screenattr(2, 1)
normal yyP
redraw
- " Line 1 has cursor so it should be highlighted with CursorLine.
- call assert_equal(cul_attr, screenattr(1, 1))
- " And CursorLine highlighting from the second line should be gone.
- call assert_equal(std_attr, screenattr(2, 1))
+ " Line 2 has cursor so it should be highlighted with CursorLine.
+ call assert_equal(cul_attr, screenattr(2, 1))
+ " And CursorLine highlighting from line 3 should be gone.
+ call assert_equal(std_attr, screenattr(3, 1))
set nocursorline
bwipe!
endfunc
@@ -810,6 +810,7 @@ endfunc
" Test for :highlight command errors
func Test_highlight_cmd_errors()
if has('gui_running') || has('nvim')
+ hi! Normal ctermfg=NONE ctermbg=NONE
" This test doesn't fail in the MS-Windows console version.
call assert_fails('hi Xcomment ctermfg=fg', 'E419:')
call assert_fails('hi Xcomment ctermfg=bg', 'E420:')
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
index e1c8b82908..917c37c324 100644
--- a/test/old/testdir/test_ins_complete.vim
+++ b/test/old/testdir/test_ins_complete.vim
@@ -108,6 +108,19 @@ func Test_ins_complete()
call delete('Xdir', 'rf')
endfunc
+func Test_ins_complete_invalid_byte()
+ if has('unix') && executable('base64')
+ " this weird command was causing an illegal memory access
+ call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64')
+ call system('base64 -d Xinvalid64 > Xinvalid')
+ call writefile(['qa!'], 'Xexit')
+ call RunVim([], [], " -i NONE -n -X -Z -e -m -s -S Xinvalid -S Xexit")
+ call delete('Xinvalid64')
+ call delete('Xinvalid')
+ call delete('Xexit')
+ endif
+endfunc
+
func Test_omni_dash()
func Omni(findstart, base)
if a:findstart
@@ -2407,4 +2420,18 @@ func Test_complete_info_index()
bwipe!
endfunc
-" vim: shiftwidth=2 sts=2 expandtab
+func Test_complete_changed_complete_info()
+ CheckRunVimInTerminal
+ " this used to crash vim, see #13929
+ let lines =<< trim END
+ set completeopt=menuone
+ autocmd CompleteChanged * call complete_info(['items'])
+ call feedkeys("iii\<cr>\<c-p>")
+ END
+ call writefile(lines, 'Xsegfault', 'D')
+ let buf = RunVimInTerminal('-S Xsegfault', #{rows: 5})
+ call WaitForAssert({-> assert_match('^ii', term_getline(buf, 1))}, 1000)
+ call StopVimInTerminal(buf)
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/test/old/testdir/test_lispindent.vim b/test/old/testdir/test_lispindent.vim
index 2d6060bba3..76ff4e0fd8 100644
--- a/test/old/testdir/test_lispindent.vim
+++ b/test/old/testdir/test_lispindent.vim
@@ -50,6 +50,7 @@ func Test_lisp_indent()
set lisp
set lispwords&
+ throw 'Skipped: cpo+=p not supported'
let save_copt = &cpoptions
set cpoptions+=p
normal 1G=G
diff --git a/test/old/testdir/test_listchars.vim b/test/old/testdir/test_listchars.vim
index 179bdfa4a0..b82b70746b 100644
--- a/test/old/testdir/test_listchars.vim
+++ b/test/old/testdir/test_listchars.vim
@@ -429,52 +429,52 @@ func Test_listchars_invalid()
call assert_fails('set listchars=leadmultispace', 'E474:')
" Too short
- call assert_fails('set listchars=space:', 'E474:')
- call assert_fails('set listchars=tab:x', 'E474:')
- call assert_fails('set listchars=multispace:', 'E474:')
- call assert_fails('set listchars=leadmultispace:', 'E474:')
+ call assert_fails('set listchars=space:', 'E1511:')
+ call assert_fails('set listchars=tab:x', 'E1511:')
+ call assert_fails('set listchars=multispace:', 'E1511:')
+ call assert_fails('set listchars=leadmultispace:', 'E1511:')
" One occurrence too short
- call assert_fails('set listchars=space:,space:x', 'E474:')
- call assert_fails('set listchars=space:x,space:', 'E474:')
- call assert_fails('set listchars=tab:x,tab:xx', 'E474:')
- call assert_fails('set listchars=tab:xx,tab:x', 'E474:')
- call assert_fails('set listchars=multispace:,multispace:x', 'E474:')
- call assert_fails('set listchars=multispace:x,multispace:', 'E474:')
- call assert_fails('set listchars=leadmultispace:,leadmultispace:x', 'E474:')
- call assert_fails('set listchars=leadmultispace:x,leadmultispace:', 'E474:')
+ call assert_fails('set listchars=space:x,space:', 'E1511:')
+ call assert_fails('set listchars=space:,space:x', 'E1511:')
+ call assert_fails('set listchars=tab:xx,tab:x', 'E1511:')
+ call assert_fails('set listchars=tab:x,tab:xx', 'E1511:')
+ call assert_fails('set listchars=multispace:,multispace:x', 'E1511:')
+ call assert_fails('set listchars=multispace:x,multispace:', 'E1511:')
+ call assert_fails('set listchars=leadmultispace:,leadmultispace:x', 'E1511:')
+ call assert_fails('set listchars=leadmultispace:x,leadmultispace:', 'E1511:')
" Too long
- call assert_fails('set listchars=space:xx', 'E474:')
- call assert_fails('set listchars=tab:xxxx', 'E474:')
+ call assert_fails('set listchars=space:xx', 'E1511:')
+ call assert_fails('set listchars=tab:xxxx', 'E1511:')
" Has double-width character
- call assert_fails('set listchars=space:·', 'E474:')
- call assert_fails('set listchars=tab:·x', 'E474:')
- call assert_fails('set listchars=tab:x·', 'E474:')
- call assert_fails('set listchars=tab:xx·', 'E474:')
- call assert_fails('set listchars=multispace:·', 'E474:')
- call assert_fails('set listchars=multispace:xxx·', 'E474:')
- call assert_fails('set listchars=leadmultispace:·', 'E474:')
- call assert_fails('set listchars=leadmultispace:xxx·', 'E474:')
+ call assert_fails('set listchars=space:·', 'E1512:')
+ call assert_fails('set listchars=tab:·x', 'E1512:')
+ call assert_fails('set listchars=tab:x·', 'E1512:')
+ call assert_fails('set listchars=tab:xx·', 'E1512:')
+ call assert_fails('set listchars=multispace:·', 'E1512:')
+ call assert_fails('set listchars=multispace:xxx·', 'E1512:')
+ call assert_fails('set listchars=leadmultispace:·', 'E1512:')
+ call assert_fails('set listchars=leadmultispace:xxx·', 'E1512:')
" Has control character
- call assert_fails("set listchars=space:\x01", 'E474:')
- call assert_fails("set listchars=tab:\x01x", 'E474:')
- call assert_fails("set listchars=tab:x\x01", 'E474:')
- call assert_fails("set listchars=tab:xx\x01", 'E474:')
- call assert_fails("set listchars=multispace:\x01", 'E474:')
- call assert_fails("set listchars=multispace:xxx\x01", 'E474:')
- call assert_fails('set listchars=space:\\x01', 'E474:')
- call assert_fails('set listchars=tab:\\x01x', 'E474:')
- call assert_fails('set listchars=tab:x\\x01', 'E474:')
- call assert_fails('set listchars=tab:xx\\x01', 'E474:')
- call assert_fails('set listchars=multispace:\\x01', 'E474:')
- call assert_fails('set listchars=multispace:xxx\\x01', 'E474:')
- call assert_fails("set listchars=leadmultispace:\x01", 'E474:')
- call assert_fails('set listchars=leadmultispace:\\x01', 'E474:')
- call assert_fails("set listchars=leadmultispace:xxx\x01", 'E474:')
- call assert_fails('set listchars=leadmultispace:xxx\\x01', 'E474:')
+ call assert_fails("set listchars=space:\x01", 'E1512:')
+ call assert_fails("set listchars=tab:\x01x", 'E1512:')
+ call assert_fails("set listchars=tab:x\x01", 'E1512:')
+ call assert_fails("set listchars=tab:xx\x01", 'E1512:')
+ call assert_fails("set listchars=multispace:\x01", 'E1512:')
+ call assert_fails("set listchars=multispace:xxx\x01", 'E1512:')
+ call assert_fails('set listchars=space:\\x01', 'E1512:')
+ call assert_fails('set listchars=tab:\\x01x', 'E1512:')
+ call assert_fails('set listchars=tab:x\\x01', 'E1512:')
+ call assert_fails('set listchars=tab:xx\\x01', 'E1512:')
+ call assert_fails('set listchars=multispace:\\x01', 'E1512:')
+ call assert_fails('set listchars=multispace:xxx\\x01', 'E1512:')
+ call assert_fails("set listchars=leadmultispace:\x01", 'E1512:')
+ call assert_fails('set listchars=leadmultispace:\\x01', 'E1512:')
+ call assert_fails("set listchars=leadmultispace:xxx\x01", 'E1512:')
+ call assert_fails('set listchars=leadmultispace:xxx\\x01', 'E1512:')
enew!
set ambiwidth& listchars& ff&
diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim
index fef7c6a9bc..649d5f5c6c 100644
--- a/test/old/testdir/test_listdict.vim
+++ b/test/old/testdir/test_listdict.vim
@@ -456,6 +456,25 @@ func Test_dict_func_remove()
call CheckLegacyAndVim9Failure(lines, 'E716:')
let lines =<< trim END
+ let d = {'a-b': 55}
+ echo d.a-b
+ END
+ call CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"')
+
+ let lines =<< trim END
+ vim9script
+ var d = {'a-b': 55}
+ echo d.a-b
+ END
+ call CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"')
+
+ let lines =<< trim END
+ var d = {'a-b': 55}
+ echo d.a-b
+ END
+ call CheckDefFailure(lines, 'E1004: White space required before and after ''-''')
+
+ let lines =<< trim END
let d = {1: 'a', 3: 'c'}
call remove(d, [])
END
@@ -1302,7 +1321,7 @@ func Test_listdict_index()
call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[1.1] = 4'], ['E805:', 'E1012:', 'E805:'])
call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: i] = [4, 5]'], ['E121:', 'E1001:', 'E121:'])
call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: 3.2] = [4, 5]'], ['E805:', 'E1012:', 'E805:'])
- " call CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], 'E685:')
+ " call CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], ['E685:', 'E909:', 'E685:'])
endfunc
" Test for a null list
diff --git a/test/old/testdir/test_listlbr.vim b/test/old/testdir/test_listlbr.vim
index 6dea94fbf1..e9bf9f3ff2 100644
--- a/test/old/testdir/test_listlbr.vim
+++ b/test/old/testdir/test_listlbr.vim
@@ -375,13 +375,13 @@ endfunc
func Test_linebreak_no_break_after_whitespace_only()
call s:test_windows('setl ts=4 linebreak wrap')
- call setline(1, "\tabcdefghijklmnopqrstuvwxyz" ..
+ call setline(1, "\t abcdefghijklmnopqrstuvwxyz" ..
\ "abcdefghijklmnopqrstuvwxyz")
let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [
-\ " abcdefghijklmnop",
-\ "qrstuvwxyzabcdefghij",
-\ "klmnopqrstuvwxyz ",
+\ " abcdefghijklmn",
+\ "opqrstuvwxyzabcdefgh",
+\ "ijklmnopqrstuvwxyz ",
\ "~ ",
\ ]
call s:compare_lines(expect, lines)
diff --git a/test/old/testdir/test_listlbr_utf8.vim b/test/old/testdir/test_listlbr_utf8.vim
index 1bbbd2d2ae..313ff30cc4 100644
--- a/test/old/testdir/test_listlbr_utf8.vim
+++ b/test/old/testdir/test_listlbr_utf8.vim
@@ -9,6 +9,7 @@ CheckFeature conceal
CheckFeature signs
source view_util.vim
+source screendump.vim
func s:screen_lines(lnum, width) abort
return ScreenLines(a:lnum, a:width)
@@ -358,4 +359,24 @@ func Test_unprintable_char_on_wrap_column()
call s:close_windows()
endfunc
+" Test that Visual selection is drawn correctly when 'linebreak' is set and
+" selection ends before multibyte 'showbreak'.
+func Test_visual_ends_before_showbreak()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ &wrap = true
+ &linebreak = true
+ &showbreak = '↪ '
+ ['xxxxx ' .. 'y'->repeat(&columns - 6) .. ' zzzz']->setline(1)
+ normal! wvel
+ END
+ call writefile(lines, 'XvisualEndsBeforeShowbreak', 'D')
+ let buf = RunVimInTerminal('-S XvisualEndsBeforeShowbreak', #{rows: 6})
+ call VerifyScreenDump(buf, 'Test_visual_ends_before_showbreak', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_map_functions.vim b/test/old/testdir/test_map_functions.vim
index 2aeb470a0d..0898242154 100644
--- a/test/old/testdir/test_map_functions.vim
+++ b/test/old/testdir/test_map_functions.vim
@@ -593,7 +593,7 @@ func Test_maplist()
call assert_equal(len(maps_maplist), len(map_set))
" For everything returned by maplist, should be the same as from maparg.
- " Except for "map dup", bacause maparg returns the <buffer> version
+ " Except for "map dup", because maparg returns the <buffer> version
for d in maps_maplist
if d.lhs == 'dup' && d.buffer == 0
continue
diff --git a/test/old/testdir/test_mapping.vim b/test/old/testdir/test_mapping.vim
index 36a46684c1..623228b347 100644
--- a/test/old/testdir/test_mapping.vim
+++ b/test/old/testdir/test_mapping.vim
@@ -108,7 +108,7 @@ func Test_map_langmap()
unmap x
bwipe!
- " 'langnoremap' follows 'langremap' and vise versa
+ " 'langnoremap' follows 'langremap' and vice versa
set langremap
set langnoremap
call assert_equal(0, &langremap)
@@ -235,6 +235,24 @@ func Test_map_meta_multibyte()
iunmap <M-á>
endfunc
+func Test_map_super_quotes()
+ if has('gui_gtk') || has('gui_gtk3') || has("macos")
+ imap <D-"> foo
+ call feedkeys("Go-\<*D-\">-\<Esc>", "xt")
+ call assert_equal("-foo-", getline('$'))
+ set nomodified
+ iunmap <D-">
+ endif
+endfunc
+
+func Test_map_super_multibyte()
+ if has('gui_gtk') || has('gui_gtk3') || has("macos")
+ imap <D-á> foo
+ call assert_match('i <D-á>\s*foo', execute('imap'))
+ iunmap <D-á>
+ endif
+endfunc
+
func Test_abbr_after_line_join()
new
abbr foo bar
diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim
index 5ebcb375b6..ac5184645f 100644
--- a/test/old/testdir/test_messages.vim
+++ b/test/old/testdir/test_messages.vim
@@ -167,8 +167,18 @@ func Test_echospace()
call assert_equal(&columns - 12, v:echospace)
set showcmd ruler
call assert_equal(&columns - 29, v:echospace)
+ set showcmdloc=statusline
+ call assert_equal(&columns - 19, v:echospace)
+ set showcmdloc=tabline
+ call assert_equal(&columns - 19, v:echospace)
+ call assert_fails('set showcmdloc=leap', 'E474:')
+ call assert_equal(&columns - 19, v:echospace)
+ set showcmdloc=last
+ call assert_equal(&columns - 29, v:echospace)
+ call assert_fails('set showcmdloc=jump', 'E474:')
+ call assert_equal(&columns - 29, v:echospace)
- set ruler& showcmd&
+ set ruler& showcmd& showcmdloc&
endfunc
func Test_warning_scroll()
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index 6a8c15bd48..91c058df9e 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -2240,7 +2240,7 @@ func Test_normal29_brace()
[DATA]
call assert_equal(expected, getline(1, '$'))
- " Test with { in cpooptions
+ " Test with { in cpoptions
%d
call append(0, text)
" Nvim: no "{" flag in 'cpoptions'.
@@ -2353,19 +2353,19 @@ func Test_normal30_changecase()
norm! 1ggVu
call assert_equal('this is a simple test: äüöß', getline('.'))
norm! VU
- call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖSS', getline('.'))
+ call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖẞ', getline('.'))
norm! guu
- call assert_equal('this is a simple test: äüöss', getline('.'))
+ call assert_equal('this is a simple test: äüöß', getline('.'))
norm! gUgU
- call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖSS', getline('.'))
+ call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖẞ', getline('.'))
norm! gugu
- call assert_equal('this is a simple test: äüöss', getline('.'))
+ call assert_equal('this is a simple test: äüöß', getline('.'))
norm! gUU
- call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖSS', getline('.'))
+ call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖẞ', getline('.'))
norm! 010~
- call assert_equal('this is a SIMPLE TEST: ÄÜÖSS', getline('.'))
+ call assert_equal('this is a SIMPLE TEST: ÄÜÖẞ', getline('.'))
norm! V~
- call assert_equal('THIS IS A simple test: äüöss', getline('.'))
+ call assert_equal('THIS IS A simple test: äüöß', getline('.'))
call assert_beeps('norm! c~')
%d
call assert_beeps('norm! ~')
@@ -3167,15 +3167,18 @@ endfunc
func Test_normal50_commandline()
CheckFeature timers
CheckFeature cmdline_hist
+
func! DoTimerWork(id)
- call assert_equal('[Command Line]', bufname(''))
+ call assert_equal(1, getbufinfo('')[0].command)
+
" should fail, with E11, but does fail with E23?
"call feedkeys("\<c-^>", 'tm')
- " should also fail with E11
+ " should fail with E11 - "Invalid in command-line window"
call assert_fails(":wincmd p", 'E11')
- " return from commandline window
- call feedkeys("\<cr>")
+
+ " Return from commandline window.
+ call feedkeys("\<CR>", 't')
endfunc
let oldlang=v:lang
@@ -3188,7 +3191,9 @@ func Test_normal50_commandline()
catch /E23/
" no-op
endtry
+
" clean up
+ delfunc DoTimerWork
set updatetime=4000
exe "lang" oldlang
bw!
@@ -4169,4 +4174,21 @@ func Test_normal34_zet_large()
norm! z9765405999999999999
endfunc
-" vim: shiftwidth=2 sts=2 expandtab
+" Test for { and } paragraph movements in a single line
+func Test_brace_single_line()
+ let text =<< trim [DATA]
+ foobar one two three
+ [DATA]
+
+ new
+ call setline(1, text)
+ 1
+ norm! 0}
+
+ call assert_equal([0, 1, 20, 0], getpos('.'))
+ norm! {
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+ bw!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/test/old/testdir/test_number.vim b/test/old/testdir/test_number.vim
index 1232db80c5..b57c1ed2c5 100644
--- a/test/old/testdir/test_number.vim
+++ b/test/old/testdir/test_number.vim
@@ -146,8 +146,7 @@ func Test_number_with_linewrap1()
call s:close_windows()
endfunc
-" Pending: https://groups.google.com/forum/#!topic/vim_dev/tzNKP7EDWYI
-func XTest_number_with_linewrap2()
+func Test_number_with_linewrap2()
call s:test_windows(3, 20)
normal! 61ia
setl number wrap
@@ -164,8 +163,7 @@ func XTest_number_with_linewrap2()
call s:close_windows()
endfunc
-" Pending: https://groups.google.com/forum/#!topic/vim_dev/tzNKP7EDWYI
-func XTest_number_with_linewrap3()
+func Test_number_with_linewrap3()
call s:test_windows(4, 20)
normal! 81ia
setl number wrap
@@ -174,7 +172,7 @@ func XTest_number_with_linewrap3()
call s:validate_cursor()
let lines = s:screen_lines(1, 4)
let expect = [
-\ "aaaaaaaa",
+\ "<<<aaaaa",
\ "aaaaaaaa",
\ "aaaaaaaa",
\ "a ",
@@ -276,11 +274,9 @@ func Test_relativenumber_colors()
set number relativenumber
hi LineNr ctermfg=red
[CODE]
- call writefile(lines, 'XTest_relnr')
+ call writefile(lines, 'XTest_relnr', 'D')
- " Check that the balloon shows up after a mouse move
let buf = RunVimInTerminal('-S XTest_relnr', {'rows': 10, 'cols': 50})
- call TermWait(buf, 50)
" Default colors
call VerifyScreenDump(buf, 'Test_relnr_colors_1', {})
@@ -295,7 +291,36 @@ func Test_relativenumber_colors()
" clean up
call StopVimInTerminal(buf)
- call delete('XTest_relnr')
+endfunc
+
+func Test_relativenumber_colors_wrapped()
+ CheckScreendump
+
+ let lines =<< trim [CODE]
+ set display=lastline scrolloff=0
+ call setline(1, range(200)->map('v:val->string()->repeat(40)'))
+ 111
+ set number relativenumber
+ hi LineNr ctermbg=red ctermfg=black
+ hi LineNrAbove ctermbg=blue ctermfg=black
+ hi LineNrBelow ctermbg=green ctermfg=black
+ [CODE]
+ call writefile(lines, 'XTest_relnr_wrap', 'D')
+
+ let buf = RunVimInTerminal('-S XTest_relnr_wrap', {'rows': 20, 'cols': 50})
+
+ call VerifyScreenDump(buf, 'Test_relnr_colors_wrapped_1', {})
+ call term_sendkeys(buf, "k")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_wrapped_2', {})
+ call term_sendkeys(buf, "2j")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_wrapped_3', {})
+ call term_sendkeys(buf, "2j")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_wrapped_4', {})
+ call term_sendkeys(buf, "k")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_wrapped_5', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
endfunc
func Test_relativenumber_callback()
@@ -313,14 +338,38 @@ func Test_relativenumber_callback()
call timer_start(300, 'Func')
END
- call writefile(lines, 'Xrnu_timer')
+ call writefile(lines, 'Xrnu_timer', 'D')
let buf = RunVimInTerminal('-S Xrnu_timer', #{rows: 8})
call TermWait(buf, 310)
call VerifyScreenDump(buf, 'Test_relativenumber_callback_1', {})
call StopVimInTerminal(buf)
- call delete('Xrnu_timer')
+endfunc
+
+" Test that line numbers below inserted/deleted lines are updated.
+func Test_number_insert_delete_lines()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, range(1, 7))
+ set number
+ call cursor(2, 1)
+ END
+ call writefile(lines, 'Xnumber_insert_delete_lines', 'D')
+
+ let buf = RunVimInTerminal('-S Xnumber_insert_delete_lines', #{rows: 8})
+ call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_1', {})
+ call term_sendkeys(buf, "dd")
+ call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_2', {})
+ call term_sendkeys(buf, "P")
+ call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_1', {})
+ call term_sendkeys(buf, "2dd")
+ call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_3', {})
+ call term_sendkeys(buf, "P")
+ call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_1', {})
+
+ call StopVimInTerminal(buf)
endfunc
" Test for displaying line numbers with 'rightleft'
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index d69828dc2e..7786f82af2 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -439,6 +439,14 @@ func Test_set_completion()
call assert_equal('"set syntax=sshdconfig', @:)
call feedkeys(":set syntax=a\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set syntax=' .. getcompletion('a*', 'syntax')->join(), @:)
+
+ if has('keymap')
+ " Expand values for 'keymap'
+ call feedkeys(":set keymap=acc\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set keymap=accents', @:)
+ call feedkeys(":set keymap=a\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set keymap=' .. getcompletion('a*', 'keymap')->join(), @:)
+ endif
endfunc
" Test handling of expanding individual string option values
@@ -813,7 +821,7 @@ func Test_set_option_errors()
call assert_fails('set winwidth=9 winminwidth=10', 'E592:')
set winwidth& winminwidth&
call assert_fails("set showbreak=\x01", 'E595:')
- call assert_fails('set t_foo=', 'E846:')
+ " call assert_fails('set t_foo=', 'E846:')
call assert_fails('set tabstop??', 'E488:')
call assert_fails('set wrapscan!!', 'E488:')
call assert_fails('set tabstop&&', 'E488:')
@@ -950,8 +958,10 @@ endfunc
func Test_set_one_column()
let out_mult = execute('set all')->split("\n")
let out_one = execute('set! all')->split("\n")
- " one column should be two to four times as many lines
- call assert_inrange(len(out_mult) * 2, len(out_mult) * 4, len(out_one))
+ call assert_true(len(out_mult) < len(out_one))
+ call assert_equal(out_one[0], '--- Options ---')
+ let options = out_one[1:]->mapnew({_, line -> line[2:]})
+ call assert_equal(sort(copy(options)), options)
endfunc
func Test_set_values()
@@ -1273,6 +1283,44 @@ func Test_shortmess_F2()
" call assert_fails('call test_getvalue("abc")', 'E475:')
endfunc
+func Test_shortmess_F3()
+ call writefile(['foo'], 'X_dummy', 'D')
+
+ set hidden
+ set autoread
+ e X_dummy
+ e Xotherfile
+ call assert_equal(['foo'], getbufline('X_dummy', 1, '$'))
+ set shortmess+=F
+ echo ''
+
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
+ call writefile(['bar'], 'X_dummy')
+ bprev
+ call assert_equal('', Screenline(&lines))
+ call assert_equal(['bar'], getbufline('X_dummy', 1, '$'))
+
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
+ call writefile(['baz'], 'X_dummy')
+ checktime
+ call assert_equal('', Screenline(&lines))
+ call assert_equal(['baz'], getbufline('X_dummy', 1, '$'))
+
+ set shortmess&
+ set autoread&
+ set hidden&
+ bwipe X_dummy
+ bwipe Xotherfile
+endfunc
+
func Test_local_scrolloff()
set so=5
set siso=7
@@ -1444,8 +1492,10 @@ endfunc
" Test for setting keycodes using set
func Test_opt_set_keycode()
- call assert_fails('set <t_k1=l', 'E474:')
- call assert_fails('set <Home=l', 'E474:')
+ " call assert_fails('set <t_k1=l', 'E474:')
+ " call assert_fails('set <Home=l', 'E474:')
+ call assert_fails('set <t_k1=l', 'E518:')
+ call assert_fails('set <Home=l', 'E518:')
set <t_k9>=abcd
" call assert_equal('abcd', &t_k9)
set <t_k9>&
@@ -2209,4 +2259,34 @@ func Test_set_wrap()
set wrap& smoothscroll& scrolloff&
endfunc
+func Test_delcombine()
+ new
+ set backspace=indent,eol,start
+
+ set delcombine
+ call setline(1, 'β̳̈:β̳̈')
+ normal! 0x
+ call assert_equal('β̈:β̳̈', getline(1))
+ exe "normal! A\<BS>"
+ call assert_equal('β̈:β̈', getline(1))
+ normal! 0x
+ call assert_equal('β:β̈', getline(1))
+ exe "normal! A\<BS>"
+ call assert_equal('β:β', getline(1))
+ normal! 0x
+ call assert_equal(':β', getline(1))
+ exe "normal! A\<BS>"
+ call assert_equal(':', getline(1))
+
+ set nodelcombine
+ call setline(1, 'β̳̈:β̳̈')
+ normal! 0x
+ call assert_equal(':β̳̈', getline(1))
+ exe "normal! A\<BS>"
+ call assert_equal(':', getline(1))
+
+ set backspace& delcombine&
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index fa0df77ab5..56c881b958 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -1142,6 +1142,10 @@ func Test_CompleteChanged()
let g:event = copy(v:event)
let g:item = get(v:event, 'completed_item', {})
let g:word = get(g:item, 'word', v:null)
+ let l:line = getline('.')
+ if g:word == v:null && l:line == "bc"
+ let g:word = l:line
+ endif
endfunction
augroup AAAAA_Group
au!
@@ -1161,10 +1165,24 @@ func Test_CompleteChanged()
call assert_equal(v:null, g:word)
call feedkeys("a\<C-N>\<C-N>\<C-N>\<C-N>\<C-P>", 'tx')
call assert_equal('foobar', g:word)
+ call feedkeys("S\<C-N>bc", 'tx')
+ call assert_equal("bc", g:word)
+
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return [#{word: "one"}, #{word: "two"}, #{word: "five"}]
+ endfunc
+ set omnifunc=Omni_test
+ set completeopt=menu,menuone
+ call feedkeys("i\<C-X>\<C-O>\<BS>\<BS>\<BS>f", 'tx')
+ call assert_equal('five', g:word)
autocmd! AAAAA_Group
set complete& completeopt&
delfunc! OnPumChange
+ delfunc! Omni_test
bw!
endfunc
diff --git a/test/old/testdir/test_prompt_buffer.vim b/test/old/testdir/test_prompt_buffer.vim
index 3dfbbcece6..41e14ae427 100644
--- a/test/old/testdir/test_prompt_buffer.vim
+++ b/test/old/testdir/test_prompt_buffer.vim
@@ -298,4 +298,49 @@ func Test_prompt_appending_while_hidden()
call StopVimInTerminal(buf)
endfunc
+" Modifying a hidden buffer while leaving a prompt buffer should not prevent
+" stopping of Insert mode, and returning to the prompt buffer later should
+" restore Insert mode.
+func Test_prompt_leave_modify_hidden()
+ call CanTestPromptBuffer()
+
+ let script =<< trim END
+ file hidden
+ set bufhidden=hide
+ enew
+ new prompt
+ set buftype=prompt
+
+ inoremap <buffer> w <Cmd>wincmd w<CR>
+ inoremap <buffer> q <Cmd>bwipe!<CR>
+ autocmd BufLeave prompt call appendbufline('hidden', '$', 'Leave')
+ autocmd BufEnter prompt call appendbufline('hidden', '$', 'Enter')
+ autocmd BufWinLeave prompt call appendbufline('hidden', '$', 'Close')
+ END
+ call writefile(script, 'XpromptLeaveModifyHidden', 'D')
+
+ let buf = RunVimInTerminal('-S XpromptLeaveModifyHidden', {'rows': 10})
+ call TermWait(buf)
+
+ call term_sendkeys(buf, "a")
+ call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))})
+
+ call term_sendkeys(buf, "w")
+ call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))})
+
+ call term_sendkeys(buf, "\<C-W>w")
+ call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))})
+
+ call term_sendkeys(buf, "q")
+ call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))})
+
+ call term_sendkeys(buf, ":bwipe!\<CR>")
+ call WaitForAssert({-> assert_equal('Leave', term_getline(buf, 2))})
+ call WaitForAssert({-> assert_equal('Enter', term_getline(buf, 3))})
+ call WaitForAssert({-> assert_equal('Leave', term_getline(buf, 4))})
+ call WaitForAssert({-> assert_equal('Close', term_getline(buf, 5))})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim
index 6c4bd28386..b1cf268a58 100644
--- a/test/old/testdir/test_put.vim
+++ b/test/old/testdir/test_put.vim
@@ -12,6 +12,16 @@ func Test_put_block()
bwipe!
endfunc
+func Test_put_block_unicode()
+ new
+ call setreg('a', "À\nÀÀ\naaaaaaaaaaaa", "\<C-V>")
+ call setline(1, [' 1', ' 2', ' 3'])
+ exe "norm! \<C-V>jj\"ap"
+ let expected = ['À 1', 'ÀÀ 2', 'aaaaaaaaaaaa3']
+ call assert_equal(expected, getline(1, 3))
+ bw!
+endfunc
+
func Test_put_char_block()
new
call setline(1, ['Line 1', 'Line 2'])
@@ -284,5 +294,33 @@ func Test_put_in_last_displayed_line()
call StopVimInTerminal(buf)
endfunc
+func Test_put_visual_replace_whole_fold()
+ new
+ let lines = repeat(['{{{1', 'foo', 'bar', ''], 2)
+ call setline(1, lines)
+ setlocal foldmethod=marker
+ call setreg('"', 'baz')
+ call setreg('1', '')
+ normal! Vp
+ call assert_equal("{{{1\nfoo\nbar\n\n", getreg('1'))
+ call assert_equal(['baz', '{{{1', 'foo', 'bar', ''], getline(1, '$'))
+
+ bwipe!
+endfunc
+
+func Test_put_visual_replace_fold_marker()
+ new
+ let lines = repeat(['{{{1', 'foo', 'bar', ''], 4)
+ call setline(1, lines)
+ setlocal foldmethod=marker
+ normal! Gkzo
+ call setreg('"', '{{{1')
+ call setreg('1', '')
+ normal! Vp
+ call assert_equal("{{{1\n", getreg('1'))
+ call assert_equal(lines, getline(1, '$'))
+
+ bwipe!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_python3.vim b/test/old/testdir/test_python3.vim
index 23c63f22d8..c9dbc0b84e 100644
--- a/test/old/testdir/test_python3.vim
+++ b/test/old/testdir/test_python3.vim
@@ -169,7 +169,7 @@ func Test_Catch_Exception_Message()
try
py3 raise RuntimeError( 'TEST' )
catch /.*/
- call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception )
+ call assert_match('^Vim(.*):.*RuntimeError: TEST.*$', v:exception )
endtry
endfunc
diff --git a/test/old/testdir/test_pyx3.vim b/test/old/testdir/test_pyx3.vim
index 09ece6f812..89a3cc22ff 100644
--- a/test/old/testdir/test_pyx3.vim
+++ b/test/old/testdir/test_pyx3.vim
@@ -76,7 +76,7 @@ func Test_Catch_Exception_Message()
try
pyx raise RuntimeError( 'TEST' )
catch /.*/
- call assert_match('^Vim(.*):.*RuntimeError: TEST$', v:exception )
+ call assert_match('^Vim(.*):.*RuntimeError: TEST.*$', v:exception )
endtry
endfunc
diff --git a/test/old/testdir/test_regexp_utf8.vim b/test/old/testdir/test_regexp_utf8.vim
index 2253242a7c..97f48a0c09 100644
--- a/test/old/testdir/test_regexp_utf8.vim
+++ b/test/old/testdir/test_regexp_utf8.vim
@@ -599,5 +599,16 @@ func Test_match_too_complicated()
set regexpengine=0
endfunc
+func Test_combining_chars_in_collection()
+ new
+ for i in range(0,2)
+ exe "set re=".i
+ put =['ɔ̃', 'ɔ', '̃ ã', 'abcd']
+ :%s/[ɔ̃]//
+ call assert_equal(['', '', 'ɔ', '̃ ã', 'abcd'], getline(1,'$'))
+ %d
+ endfor
+ bw!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_registers.vim b/test/old/testdir/test_registers.vim
index 01f9507916..e113bd9e75 100644
--- a/test/old/testdir/test_registers.vim
+++ b/test/old/testdir/test_registers.vim
@@ -175,7 +175,7 @@ func Test_recording_status_in_ex_line()
call assert_equal('recording @x', Screenline(&lines))
set shortmess=q
redraw!
- call assert_equal('recording', Screenline(&lines))
+ call assert_equal('', Screenline(&lines)) " Nvim: shm+=q fully hides message
set shortmess&
norm q
redraw!
@@ -801,6 +801,23 @@ func Test_end_reg_executing()
bwipe!
endfunc
+func Test_reg_executing_in_range_normal()
+ new
+ set showcmd
+ call setline(1, range(10))
+ let g:log = []
+ nnoremap s <Cmd>let g:log += [reg_executing()]<CR>
+ let @r = 's'
+
+ %normal @r
+ call assert_equal(repeat(['r'], 10), g:log)
+
+ nunmap s
+ unlet g:log
+ set showcmd&
+ bwipe!
+endfunc
+
" An operator-pending mode mapping shouldn't be applied to keys typed in
" Insert mode immediately after a character search when replaying.
func Test_replay_charsearch_omap()
@@ -812,6 +829,8 @@ func Test_replay_charsearch_omap()
call timer_start(10, {-> feedkeys(",bar\<Esc>q", 't')})
call feedkeys('qrct[', 'xt!')
call assert_equal(',bar[blah]', getline(1))
+ call assert_equal("ct[\<Ignore>,bar\<Esc>", @r)
+ call assert_equal('ct[<Ignore>,bar<Esc>', keytrans(@r))
undo
call assert_equal('foo[blah]', getline(1))
call feedkeys('@r', 'xt!')
@@ -821,5 +840,88 @@ func Test_replay_charsearch_omap()
bwipe!
endfunc
+" Make sure that y_append is correctly reset
+" and the previous register is working as expected
+func Test_register_y_append_reset()
+ new
+ call setline(1, ['1',
+ \ '2 ----------------------------------------------------',
+ \ '3',
+ \ '4',
+ \ '5 ----------------------------------------------------',
+ \ '6',
+ \ '7',
+ \ '8 ----------------------------------------------------',
+ \ '9',
+ \ '10 aaaaaaa 4.',
+ \ '11 Game Dbl-Figures Leaders:',
+ \ '12 Player Pts FG% 3P% FT% RB AS BL ST TO PF EFF',
+ \ '13 bbbbbbbbb 12 (50 /0 /67 )/ 7/ 3/ 0/ 2/ 3/ 4/+15',
+ \ '14 cccccc 12 (57 /67 /100)/ 2/ 1/ 1/ 0/ 1/ 3/+12',
+ \ '15 ddddddd 10 (63 /0 /0 )/ 1/ 3/ 0/ 3/ 5/ 3/ +9',
+ \ '16 4 5-15 0-3 2-2 5-12 1-1 3-4 33.3 0.0 100 41.7 100 75 12 14',
+ \ '17 F 23-55 2-10 9-11 23-52 3-13 26-29 41.8 20 81.8 44.2 23.1 89.7 57 75',
+ \ '18 4 3 6 3 2 3 3 4 3 3 7 3 1 4 6 -1 -1 +2 -1 -2',
+ \ '19 F 13 19 5 10 4 17 22 9 14 32 13 4 20 17 -1 -13 -4 -3 -3 +5'])
+ 11
+ exe "norm! \"a5dd"
+ norm! j
+ exe "norm! \"bY"
+ norm! 2j
+ exe "norm! \"BY"
+ norm! 4k
+ norm! 5dd
+ norm! 3k
+ " The next put should put the content of the unnamed register, not of
+ " register b!
+ norm! p
+ call assert_equal(['1',
+ \ '2 ----------------------------------------------------',
+ \ '3',
+ \ '4',
+ \ '5 ----------------------------------------------------',
+ \ '6',
+ \ '10 aaaaaaa 4.',
+ \ '16 4 5-15 0-3 2-2 5-12 1-1 3-4 33.3 0.0 100 41.7 100 75 12 14',
+ \ '17 F 23-55 2-10 9-11 23-52 3-13 26-29 41.8 20 81.8 44.2 23.1 89.7 57 75',
+ \ '18 4 3 6 3 2 3 3 4 3 3 7 3 1 4 6 -1 -1 +2 -1 -2',
+ \ '19 F 13 19 5 10 4 17 22 9 14 32 13 4 20 17 -1 -13 -4 -3 -3 +5',
+ \ '7',
+ \ '8 ----------------------------------------------------',
+ \ '9'], getline(1,'$'))
+ bwipe!
+endfunc
+
+func Test_insert_small_delete_replace_mode()
+ new
+ call setline(1, ['foo', 'bar', 'foobar', 'bar'])
+ let @- = 'foo'
+ call cursor(2, 1)
+ exe ":norm! R\<C-R>-\<C-R>-"
+ call assert_equal('foofoo', getline(2))
+ call cursor(3, 1)
+ norm! D
+ call assert_equal(['foo', 'foofoo', '', 'bar'], getline(1, 4))
+ call cursor(4, 2)
+ exe ":norm! R\<C-R>-ZZZZ"
+ call assert_equal(['foo', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4))
+ call cursor(1, 1)
+ let @- = ''
+ exe ":norm! R\<C-R>-ZZZ"
+ call assert_equal(['ZZZ', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4))
+ let @- = 'βbβ'
+ call cursor(4, 1)
+ exe ":norm! R\<C-R>-"
+ call assert_equal(['ZZZ', 'foofoo', '', 'βbβobarZZZZ'], getline(1, 4))
+ let @- = 'bβb'
+ call cursor(4, 1)
+ exe ":norm! R\<C-R>-"
+ call assert_equal(['ZZZ', 'foofoo', '', 'bβbobarZZZZ'], getline(1, 4))
+ let @- = 'βbβ'
+ call cursor(4, 1)
+ exe ":norm! R\<C-R>-"
+ call assert_equal(['ZZZ', 'foofoo', '', 'βbβobarZZZZ'], getline(1, 4))
+ bwipe!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index f2e7bc6b56..a1987ed3c9 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -923,7 +923,7 @@ func Test_smoothscroll_cursor_top()
exe "norm G3\<C-E>k"
END
call writefile(lines, 'XSmoothScrollCursorTop', 'D')
- let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCursorTop', #{rows: 12, cols:40})
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCursorTop', #{rows: 12, cols: 40})
call VerifyScreenDump(buf, 'Test_smoothscroll_cursor_top', {})
call StopVimInTerminal(buf)
@@ -942,10 +942,25 @@ func Test_smoothscroll_crash()
exe "norm! 0\<c-e>"
END
call writefile(lines, 'XSmoothScrollCrash', 'D')
- let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols:40})
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols: 40})
call term_sendkeys(buf, "2\<C-E>\<C-L>")
call StopVimInTerminal(buf)
endfunc
+func Test_smoothscroll_insert_bottom()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, repeat([repeat('A very long line ...', 10)], 5))
+ set wrap smoothscroll scrolloff=0
+ END
+ call writefile(lines, 'XSmoothScrollInsertBottom', 'D')
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollInsertBottom', #{rows: 9, cols: 40})
+ call term_sendkeys(buf, "Go123456789\<CR>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_insert_bottom', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_syntax.vim b/test/old/testdir/test_syntax.vim
index 76a21adc57..711b2adf7c 100644
--- a/test/old/testdir/test_syntax.vim
+++ b/test/old/testdir/test_syntax.vim
@@ -197,14 +197,14 @@ func Test_syntax_completion()
" Check that clearing "Aap" avoids it showing up before Boolean.
hi @Aap ctermfg=blue
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('^"syn list @Aap @boolean @character ', @:)
+ call assert_match('^"syn list @Aap @attribute @boolean @character ', @:)
hi clear @Aap
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('^"syn list @boolean @character ', @:)
+ call assert_match('^"syn list @attribute @boolean @character ', @:)
call feedkeys(":syn match \<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('^"syn match @boolean @character ', @:)
+ call assert_match('^"syn match @attribute @boolean @character ', @:)
syn cluster Aax contains=Aap
call feedkeys(":syn list @A\<C-A>\<C-B>\"\<CR>", 'tx')
@@ -214,7 +214,7 @@ endfunc
func Test_echohl_completion()
call feedkeys(":echohl no\<C-A>\<C-B>\"\<CR>", 'tx')
" call assert_equal('"echohl NonText Normal none', @:)
- call assert_equal('"echohl NonText Normal NormalFloat none', @:)
+ call assert_equal('"echohl NonText Normal NormalFloat NormalNC none', @:)
endfunc
func Test_syntax_arg_skipped()
diff --git a/test/old/testdir/test_tabpage.vim b/test/old/testdir/test_tabpage.vim
index 4e7b09b9e7..0f038c8bee 100644
--- a/test/old/testdir/test_tabpage.vim
+++ b/test/old/testdir/test_tabpage.vim
@@ -156,14 +156,85 @@ func Test_tabpage_drop()
tab split f3
normal! gt
call assert_equal(1, tabpagenr())
+ tab drop f4
+ call assert_equal(1, tabpagenr('#'))
tab drop f3
- call assert_equal(3, tabpagenr())
- call assert_equal(1, tabpagenr('#'))
+ call assert_equal(4, tabpagenr())
+ call assert_equal(2, tabpagenr('#'))
+ bwipe!
bwipe!
bwipe!
bwipe!
call assert_equal(1, tabpagenr('$'))
+
+ call assert_equal(1, winnr('$'))
+ call assert_equal('', bufname(''))
+ call writefile(['L1', 'L2'], 'Xdropfile', 'D')
+
+ " Test for ':tab drop single-file': reuse current buffer
+ let expected_nr = bufnr()
+ tab drop Xdropfile
+ call assert_equal(1, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ bwipe!
+
+ " Test for ':tab drop single-file': not reuse modified buffer
+ set modified
+ let expected_nr = bufnr() + 1
+ tab drop Xdropfile
+ call assert_equal(2, tabpagenr())
+ call assert_equal(2, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ bwipe!
+
+ " Test for ':tab drop single-file': multiple tabs already exist
+ tab split f2
+ tab split f3
+ let expected_nr = bufnr() + 1
+ tab drop Xdropfile
+ call assert_equal(4, tabpagenr())
+ call assert_equal(4, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
+
+ " Test for ':tab drop multi-files': reuse current buffer
+ let expected_nr = bufnr()
+ tab drop Xdropfile f1 f2 f3
+ call assert_equal(1, tabpagenr())
+ call assert_equal(4, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
+
+ " Test for ':tab drop multi-files': not reuse modified buffer
+ set modified
+ let expected_nr = bufnr() + 1
+ tab drop Xdropfile f1 f2 f3
+ call assert_equal(2, tabpagenr())
+ call assert_equal(5, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
+
+ " Test for ':tab drop multi-files': multiple tabs already exist
+ tab split f2
+ tab split f3
+ let expected_nr = bufnr() + 1
+ tab drop a b c
+ call assert_equal(4, tabpagenr())
+ call assert_equal(6, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ let expected_nr = bufnr() + 3
+ tab drop Xdropfile f1 f2 f3
+ call assert_equal(5, tabpagenr())
+ call assert_equal(8, tabpagenr('$'))
+ call assert_equal(expected_nr, bufnr())
+ call assert_equal('L2', getline(2))
+ %bwipe!
endfunc
" Test autocommands
@@ -260,14 +331,14 @@ function Test_tabpage_with_autocmd_tab_drop()
let s:li = []
tab drop test1
- call assert_equal(['BufLeave', 'BufEnter'], s:li)
+ call assert_equal(['BufEnter'], s:li)
let s:li = []
tab drop test2 test3
call assert_equal([
\ 'TabLeave', 'TabEnter', 'TabLeave', 'TabEnter',
\ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter',
- \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li)
+ \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter', 'BufEnter'], s:li)
autocmd! TestTabpageGroup
augroup! TestTabpageGroup
@@ -905,4 +976,40 @@ func Test_tabpage_last_line()
bwipe!
endfunc
+" this was causing an endless loop
+func Test_tabpage_drop_tabmove()
+ augroup TestTabpageTabmove
+ au!
+ autocmd! TabEnter * :if tabpagenr() > 1 | tabmove - | endif
+ augroup end
+ $tab drop XTab_99.log
+ $tab drop XTab_98.log
+ $tab drop XTab_97.log
+
+ autocmd! TestTabpageTabmove
+ augroup! TestTabpageTabmove
+
+ " clean up
+ bwipe!
+ bwipe!
+ bwipe!
+endfunc
+
+" Test that settabvar() shouldn't change the last accessed tabpage.
+func Test_lastused_tabpage_settabvar()
+ tabonly!
+ tabnew
+ tabnew
+ tabnew
+ call assert_equal(3, tabpagenr('#'))
+
+ call settabvar(2, 'myvar', 'tabval')
+ call assert_equal('tabval', gettabvar(2, 'myvar'))
+ call assert_equal(3, tabpagenr('#'))
+
+ bwipe!
+ bwipe!
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_tagjump.vim b/test/old/testdir/test_tagjump.vim
index 2ef5bd720b..ff1110e070 100644
--- a/test/old/testdir/test_tagjump.vim
+++ b/test/old/testdir/test_tagjump.vim
@@ -907,14 +907,14 @@ func Test_tag_last_search_pat()
\ "first\tXfoo\t/^int first() {}/",
\ "second\tXfoo\t/^int second() {}/",
\ "third\tXfoo\t/^int third() {}/"],
- \ 'Xtags')
+ \ 'Xtags', 'D')
set tags=Xtags
let code =<< trim [CODE]
int first() {}
int second() {}
int third() {}
[CODE]
- call writefile(code, 'Xfoo')
+ call writefile(code, 'Xfoo', 'D')
enew
let save_cpo = &cpo
@@ -924,8 +924,6 @@ func Test_tag_last_search_pat()
call assert_equal('^int second() {}', @/)
let &cpo = save_cpo
- call delete('Xtags')
- call delete('Xfoo')
set tags&
%bwipe
endfunc
@@ -936,27 +934,42 @@ func Test_tag_stack()
for i in range(10, 31)
let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"]
endfor
- call writefile(l, 'Xtags')
+ call writefile(l, 'Xtags', 'D')
set tags=Xtags
let l = []
for i in range(10, 31)
let l += ["int var" .. i .. ";"]
endfor
- call writefile(l, 'Xfoo')
+ call writefile(l, 'Xfoo', 'D')
- " Jump to a tag when the tag stack is full. Oldest entry should be removed.
enew
+ " Jump to a tag when the tag stack is full. Oldest entry should be removed.
for i in range(10, 30)
exe "tag var" .. i
endfor
- let l = gettagstack()
- call assert_equal(20, l.length)
- call assert_equal('var11', l.items[0].tagname)
+ let t = gettagstack()
+ call assert_equal(20, t.length)
+ call assert_equal('var11', t.items[0].tagname)
+ let full = deepcopy(t.items)
tag var31
- let l = gettagstack()
- call assert_equal('var12', l.items[0].tagname)
- call assert_equal('var31', l.items[19].tagname)
+ let t = gettagstack()
+ call assert_equal('var12', t.items[0].tagname)
+ call assert_equal('var31', t.items[19].tagname)
+
+ " Jump to a tag when the tag stack is full, but with user data this time.
+ call foreach(full, {i, item -> extend(item, {'user_data': $'udata{i}'})})
+ call settagstack(0, {'items': full})
+ let t = gettagstack()
+ call assert_equal(20, t.length)
+ call assert_equal('var11', t.items[0].tagname)
+ call assert_equal('udata0', t.items[0].user_data)
+ tag var31
+ let t = gettagstack()
+ call assert_equal('var12', t.items[0].tagname)
+ call assert_equal('udata1', t.items[0].user_data)
+ call assert_equal('var31', t.items[19].tagname)
+ call assert_false(has_key(t.items[19], 'user_data'))
" Use tnext with a single match
call assert_fails('tnext', 'E427:')
@@ -988,8 +1001,6 @@ func Test_tag_stack()
call settagstack(1, {'items' : []})
call assert_fails('pop', 'E73:')
- call delete('Xtags')
- call delete('Xfoo')
set tags&
%bwipe
endfunc
diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim
index 98a4bd3215..33cdaf1611 100644
--- a/test/old/testdir/test_termdebug.vim
+++ b/test/old/testdir/test_termdebug.vim
@@ -18,9 +18,8 @@ if g:GCC->empty()
throw 'Skipped: gcc is not found in $PATH'
endif
-packadd termdebug
-
-func Test_termdebug_basic()
+function s:generate_files(bin_name)
+ let src_name = a:bin_name .. '.c'
let lines =<< trim END
#include <stdio.h>
#include <stdlib.h>
@@ -46,8 +45,21 @@ func Test_termdebug_basic()
return 0;
}
END
- call writefile(lines, 'XTD_basic.c', 'D')
- call system($'{g:GCC} -g -o XTD_basic XTD_basic.c')
+ call writefile(lines, src_name)
+ call system($'{g:GCC} -g -o {a:bin_name} {src_name}')
+endfunction
+
+function s:cleanup_files(bin_name)
+ call delete(a:bin_name)
+ call delete(a:bin_name .. '.c')
+endfunction
+
+packadd termdebug
+
+func Test_termdebug_basic()
+ let bin_name = 'XTD_basic'
+ let src_name = bin_name .. '.c'
+ call s:generate_files(bin_name)
edit XTD_basic.c
Termdebug ./XTD_basic
@@ -149,7 +161,72 @@ func Test_termdebug_basic()
call WaitForAssert({-> assert_equal(1, winnr('$'))})
call assert_equal([], sign_getplaced('', #{group: 'TermDebug'})[0].signs)
- call delete('XTD_basic')
+ call s:cleanup_files(bin_name)
+ %bw!
+endfunc
+
+func Test_termdebug_tbreak()
+ let g:test_is_flaky = 1
+ let bin_name = 'XTD_tbreak'
+ let src_name = bin_name .. '.c'
+
+ eval s:generate_files(bin_name)
+
+ execute 'edit ' .. src_name
+ execute 'Termdebug ./' .. bin_name
+
+ call WaitForAssert({-> assert_equal(3, winnr('$'))})
+ let gdb_buf = winbufnr(1)
+ wincmd b
+
+ let bp_line = 22 " 'return' statement in main
+ let temp_bp_line = 10 " 'if' statement in 'for' loop body
+ execute "Tbreak " .. temp_bp_line
+ execute "Break " .. bp_line
+
+ call Nterm_wait(gdb_buf)
+ redraw!
+ " both temporary and normal breakpoint signs were displayed...
+ call assert_equal([
+ \ {'lnum': temp_bp_line, 'id': 1014, 'name': 'debugBreakpoint1.0',
+ \ 'priority': 110, 'group': 'TermDebug'},
+ \ {'lnum': bp_line, 'id': 2014, 'name': 'debugBreakpoint2.0',
+ \ 'priority': 110, 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)
+
+ Run
+ call Nterm_wait(gdb_buf, 400)
+ redraw!
+ " debugPC sign is on the line where the temp. bp was set;
+ " temp. bp sign was removed after hit;
+ " normal bp sign is still present
+ call WaitForAssert({-> assert_equal([
+ \ {'lnum': temp_bp_line, 'id': 12, 'name': 'debugPC', 'priority': 110,
+ \ 'group': 'TermDebug'},
+ \ {'lnum': bp_line, 'id': 2014, 'name': 'debugBreakpoint2.0',
+ \ 'priority': 110, 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)})
+
+ Continue
+ call Nterm_wait(gdb_buf)
+ redraw!
+ " debugPC is on the normal breakpoint,
+ " temp. bp on line 10 was only hit once
+ call WaitForAssert({-> assert_equal([
+ \ {'lnum': bp_line, 'id': 12, 'name': 'debugPC', 'priority': 110,
+ \ 'group': 'TermDebug'},
+ \ {'lnum': bp_line, 'id': 2014, 'name': 'debugBreakpoint2.0',
+ \ 'priority': 110, 'group': 'TermDebug'}],
+ "\ sign_getplaced('', #{group: 'TermDebug'})[0].signs)})
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs->reverse())})
+
+ wincmd t
+ quit!
+ redraw!
+ call WaitForAssert({-> assert_equal(1, winnr('$'))})
+ call assert_equal([], sign_getplaced('', #{group: 'TermDebug'})[0].signs)
+
+ eval s:cleanup_files(bin_name)
%bw!
endfunc
diff --git a/test/old/testdir/test_textobjects.vim b/test/old/testdir/test_textobjects.vim
index f21d6fcb99..3b86ae97da 100644
--- a/test/old/testdir/test_textobjects.vim
+++ b/test/old/testdir/test_textobjects.vim
@@ -402,7 +402,7 @@ func Test_paragraph()
call assert_beeps("normal Vipip")
exe "normal \<C-C>"
- close!
+ bw!
endfunc
" Tests for text object aw
@@ -608,7 +608,7 @@ func Test_textobj_quote()
normal $hhyi"
call assert_equal('bar', @")
- close!
+ bw!
endfunc
" Test for i(, i<, etc. when cursor is in front of a block
@@ -640,7 +640,133 @@ func Test_textobj_find_paren_forward()
normal 0di)
call assert_equal('foo ()', getline(1))
- close!
+ bw!
+endfunc
+
+func Test_inner_block_empty_paren()
+ new
+ call setline(1, ["(text)()", "", "(text)(", ")", "", "()()", "", "text()"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f(viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('(', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f(viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('(', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f(viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('(', @")
+
+ " Change empty inner block
+ call cursor(8, 1)
+ call feedkeys("0cibtext", "xt")
+ call assert_equal("text(text)", getline('.'))
+
+ bwipe!
+endfunc
+
+func Test_inner_block_empty_bracket()
+ new
+ call setline(1, ["[text][]", "", "[text][", "]", "", "[][]", "", "text[]"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f[viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('[', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f[viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('[', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f[viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('[', @")
+
+ " Change empty inner block
+ call cursor(8, 1)
+ call feedkeys("0ci[text", "xt")
+ call assert_equal("text[text]", getline('.'))
+
+ bwipe!
+endfunc
+
+func Test_inner_block_empty_brace()
+ new
+ call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}", "", "text{}"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f{viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('{', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f{viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('{', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f{viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('{', @")
+
+ " Change empty inner block
+ call cursor(8, 1)
+ call feedkeys("0ciBtext", "xt")
+ call assert_equal("text{text}", getline('.'))
+
+ bwipe!
+endfunc
+
+func Test_inner_block_empty_lessthan()
+ new
+ call setline(1, ["<text><>", "", "<text><", ">", "", "<><>"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f<viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('<', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f<viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('<', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f<viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('<', @")
+ bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim
index a06731cc96..a207f4f4e0 100644
--- a/test/old/testdir/test_undo.vim
+++ b/test/old/testdir/test_undo.vim
@@ -588,7 +588,7 @@ funct Test_undofile()
endif
call assert_equal('', undofile(''))
- " Test undofile() with 'undodir' set to to an existing directory.
+ " Test undofile() with 'undodir' set to an existing directory.
call mkdir('Xundodir')
set undodir=Xundodir
let cwd = getcwd()
diff --git a/test/old/testdir/test_utf8_comparisons.vim b/test/old/testdir/test_utf8_comparisons.vim
index f3c86b44fb..2c1972b087 100644
--- a/test/old/testdir/test_utf8_comparisons.vim
+++ b/test/old/testdir/test_utf8_comparisons.vim
@@ -92,3 +92,40 @@ func Test_gap()
call feedkeys("gg0g~ap", "tx")
call assert_equal(["ABCD", "", "defg"], getline(1,3))
endfunc
+
+" test that g~, ~ and gU correctly upper-cases ß
+func Test_uppercase_sharp_ss()
+ new
+ call setline(1, repeat(['ß'], 4))
+
+ call cursor(1, 1)
+ norm! ~
+ call assert_equal('ẞ', getline(line('.')))
+ norm! ~
+ call assert_equal('ß', getline(line('.')))
+
+ call cursor(2, 1)
+ norm! g~l
+ call assert_equal('ẞ', getline(line('.')))
+ norm! g~l
+ call assert_equal('ß', getline(line('.')))
+
+ call cursor(3, 1)
+ norm! gUl
+ call assert_equal('ẞ', getline(line('.')))
+ norm! vgU
+ call assert_equal('ẞ', getline(line('.')))
+ norm! vgu
+ call assert_equal('ß', getline(line('.')))
+ norm! gul
+ call assert_equal('ß', getline(line('.')))
+
+ call cursor(4, 1)
+ norm! vgU
+ call assert_equal('ẞ', getline(line('.')))
+ norm! vgu
+ call assert_equal('ß', getline(line('.')))
+ bw!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_virtualedit.vim b/test/old/testdir/test_virtualedit.vim
index 4780faa706..6448c7a3e3 100644
--- a/test/old/testdir/test_virtualedit.vim
+++ b/test/old/testdir/test_virtualedit.vim
@@ -77,13 +77,30 @@ endfunc
func Test_edit_change()
new
set virtualedit=all
+
call setline(1, "\t⒌")
normal Cx
call assert_equal('x', getline(1))
+
+ call setline(1, "\ta̳")
+ normal Cx
+ call assert_equal('x', getline(1))
+
+ call setline(1, "\tβ̳")
+ normal Cx
+ call assert_equal('x', getline(1))
+
+ if has('arabic')
+ call setline(1, "\tلا")
+ normal Cx
+ call assert_equal('x', getline(1))
+ endif
+
" Do a visual block change
call setline(1, ['a', 'b', 'c'])
exe "normal gg3l\<C-V>2jcx"
call assert_equal(['a x', 'b x', 'c x'], getline(1, '$'))
+
bwipe!
set virtualedit=
endfunc
diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim
index 5d70492451..4c5ab9f61f 100644
--- a/test/old/testdir/test_visual.vim
+++ b/test/old/testdir/test_visual.vim
@@ -3,6 +3,7 @@
source shared.vim
source check.vim
source screendump.vim
+source vim9.vim
func Test_block_shift_multibyte()
" Uses double-wide character.
@@ -1010,7 +1011,7 @@ endfunc
" Test for changing case
func Test_visual_change_case()
new
- " gUe must uppercase a whole word, also when ß changes to SS
+ " gUe must uppercase a whole word, also when ß changes to ẞ
exe "normal Gothe youtußeuu end\<Esc>Ypk0wgUe\r"
" gUfx must uppercase until x, inclusive.
exe "normal O- youßtußexu -\<Esc>0fogUfx\r"
@@ -1022,9 +1023,9 @@ func Test_visual_change_case()
exe "normal Oblah di\rdoh dut\<Esc>VkUj\r"
" Uppercase part of two lines
exe "normal ddppi333\<Esc>k0i222\<Esc>fyllvjfuUk"
- call assert_equal(['the YOUTUSSEUU end', '- yOUSSTUSSEXu -',
- \ 'THE YOUTUSSEUU END', '111THE YOUTUSSEUU END', 'BLAH DI', 'DOH DUT',
- \ '222the yoUTUSSEUU END', '333THE YOUTUßeuu end'], getline(2, '$'))
+ call assert_equal(['the YOUTUẞEUU end', '- yOUẞTUẞEXu -',
+ \ 'THE YOUTUẞEUU END', '111THE YOUTUẞEUU END', 'BLAH DI', 'DOH DUT',
+ \ '222the yoUTUẞEUU END', '333THE YOUTUßeuu end'], getline(2, '$'))
bwipe!
endfunc
@@ -1589,6 +1590,353 @@ func Test_Visual_r_CTRL_C()
call feedkeys("\<c-v>$gr\<c-c>", 'tx')
call assert_equal([''], getline(1, 1))
bw!
-endfu
+endfunc
+
+func Test_visual_drag_out_of_window()
+ rightbelow vnew
+ call setline(1, '123456789')
+ set mouse=a
+ func ClickExpr(off)
+ call Ntest_setmouse(1, getwininfo(win_getid())[0].wincol + a:off)
+ return "\<LeftMouse>"
+ endfunc
+ func DragExpr(off)
+ call Ntest_setmouse(1, getwininfo(win_getid())[0].wincol + a:off)
+ return "\<LeftDrag>"
+ endfunc
+
+ nnoremap <expr> <F2> ClickExpr(5)
+ nnoremap <expr> <F3> DragExpr(-1)
+ redraw
+ call feedkeys("\<F2>\<F3>\<LeftRelease>", 'tx')
+ call assert_equal([1, 6], [col('.'), col('v')])
+ call feedkeys("\<Esc>", 'tx')
+
+ nnoremap <expr> <F2> ClickExpr(6)
+ nnoremap <expr> <F3> DragExpr(-2)
+ redraw
+ call feedkeys("\<F2>\<F3>\<LeftRelease>", 'tx')
+ call assert_equal([1, 7], [col('.'), col('v')])
+ call feedkeys("\<Esc>", 'tx')
+
+ nunmap <F2>
+ nunmap <F3>
+ delfunc ClickExpr
+ delfunc DragExpr
+ set mouse&
+ bwipe!
+endfunc
+
+func Test_visual_substitute_visual()
+ new
+ call setline(1, ['one', 'two', 'three'])
+ call feedkeys("Gk\<C-V>j$:s/\\%V\\_.*\\%V/foobar\<CR>", 'tx')
+ call assert_equal(['one', 'foobar'], getline(1, '$'))
+ bwipe!
+endfunc
+
+func Test_visual_getregion()
+ let lines =<< trim END
+ new
+
+ call setline(1, ['one', 'two', 'three'])
+
+ #" Visual mode
+ call cursor(1, 1)
+ call feedkeys("\<ESC>vjl", 'tx')
+ call assert_equal(['one', 'tw'],
+ \ 'v'->getpos()->getregion(getpos('.')))
+ call assert_equal(['one', 'tw'],
+ \ '.'->getpos()->getregion(getpos('v')))
+ call assert_equal(['o'],
+ \ 'v'->getpos()->getregion(getpos('v')))
+ call assert_equal(['w'],
+ \ '.'->getpos()->getregion(getpos('.'), {'type': 'v' }))
+ call assert_equal(['one', 'two'],
+ \ getpos('.')->getregion(getpos('v'), {'type': 'V' }))
+ call assert_equal(['on', 'tw'],
+ \ getpos('.')->getregion(getpos('v'), {'type': "\<C-v>" }))
+
+ #" Line visual mode
+ call cursor(1, 1)
+ call feedkeys("\<ESC>Vl", 'tx')
+ call assert_equal(['one'],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'V' }))
+ call assert_equal(['one'],
+ \ getregion(getpos('.'), getpos('v'), {'type': 'V' }))
+ call assert_equal(['one'],
+ \ getregion(getpos('v'), getpos('v'), {'type': 'V' }))
+ call assert_equal(['one'],
+ \ getregion(getpos('.'), getpos('.'), {'type': 'V' }))
+ call assert_equal(['on'],
+ \ getpos('.')->getregion(getpos('v'), {'type': 'v' }))
+ call assert_equal(['on'],
+ \ getpos('.')->getregion(getpos('v'), {'type': "\<C-v>" }))
+
+ #" Block visual mode
+ call cursor(1, 1)
+ call feedkeys("\<ESC>\<C-v>ll", 'tx')
+ call assert_equal(['one'],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ call assert_equal(['one'],
+ \ getregion(getpos('.'), getpos('v'), {'type': "\<C-v>" }))
+ call assert_equal(['o'],
+ \ getregion(getpos('v'), getpos('v'), {'type': "\<C-v>" }))
+ call assert_equal(['e'],
+ \ getregion(getpos('.'), getpos('.'), {'type': "\<C-v>" }))
+ call assert_equal(['one'],
+ \ '.'->getpos()->getregion(getpos('v'), {'type': 'V' }))
+ call assert_equal(['one'],
+ \ '.'->getpos()->getregion(getpos('v'), {'type': 'v' }))
+
+ #" Using Marks
+ call setpos("'a", [0, 2, 3, 0])
+ call cursor(1, 1)
+ call assert_equal(['one', 'two'],
+ \ "'a"->getpos()->getregion(getpos('.'), {'type': 'v' }))
+ call assert_equal(['one', 'two'],
+ \ "."->getpos()->getregion(getpos("'a"), {'type': 'v' }))
+ call assert_equal(['one', 'two'],
+ \ "."->getpos()->getregion(getpos("'a"), {'type': 'V' }))
+ call assert_equal(['two'],
+ \ "'a"->getpos()->getregion(getpos("'a"), {'type': 'V' }))
+ call assert_equal(['one', 'two'],
+ \ "."->getpos()->getregion(getpos("'a"), {'type': "\<c-v>" }))
+
+ #" Using List
+ call cursor(1, 1)
+ call assert_equal(['one', 'two'],
+ \ [0, 2, 3, 0]->getregion(getpos('.'), {'type': 'v' }))
+ call assert_equal(['one', 'two'],
+ \ '.'->getpos()->getregion([0, 2, 3, 0], {'type': 'v' }))
+ call assert_equal(['one', 'two'],
+ \ '.'->getpos()->getregion([0, 2, 3, 0], {'type': 'V' }))
+ call assert_equal(['two'],
+ \ [0, 2, 3, 0]->getregion([0, 2, 3, 0], {'type': 'V' }))
+ call assert_equal(['one', 'two'],
+ \ '.'->getpos()->getregion([0, 2, 3, 0], {'type': "\<c-v>" }))
+
+ #" Multiline with line visual mode
+ call cursor(1, 1)
+ call feedkeys("\<ESC>Vjj", 'tx')
+ call assert_equal(['one', 'two', 'three'],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'V' }))
+
+ #" Multiline with block visual mode
+ call cursor(1, 1)
+ call feedkeys("\<ESC>\<C-v>jj", 'tx')
+ call assert_equal(['o', 't', 't'],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+
+ call cursor(1, 1)
+ call feedkeys("\<ESC>\<C-v>jj$", 'tx')
+ call assert_equal(['one', 'two', 'three'],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+
+ #" 'virtualedit'
+ set virtualedit=all
+ call cursor(1, 1)
+ call feedkeys("\<ESC>\<C-v>10ljj$", 'tx')
+ call assert_equal(['one ', 'two ', 'three '],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ set virtualedit&
+
+ #" Invalid position
+ call cursor(1, 1)
+ call feedkeys("\<ESC>vjj$", 'tx')
+ call assert_fails("call getregion(1, 2)", 'E1211:')
+ call assert_fails("call getregion(getpos('.'), {})", 'E1211:')
+ call assert_equal([], getregion(getpos('.'), getpos('.'), {'type': '' }))
+
+ #" using the wrong type
+ call assert_fails(':echo "."->getpos()->getregion("$", [])', 'E1211:')
+
+ #" using a mark from another buffer to current buffer
+ new
+ VAR newbuf = bufnr()
+ call setline(1, range(10))
+ normal! GmA
+ wincmd p
+ call assert_equal([newbuf, 10, 1, 0], getpos("'A"))
+ call assert_equal([], getregion(getpos('.'), getpos("'A"), {'type': 'v' }))
+ call assert_equal([], getregion(getpos("'A"), getpos('.'), {'type': 'v' }))
+ exe $':{newbuf}bwipe!'
+
+ #" using a mark from another buffer to another buffer
+ new
+ VAR anotherbuf = bufnr()
+ call setline(1, range(10))
+ normal! GmA
+ normal! GmB
+ wincmd p
+ call assert_equal([anotherbuf, 10, 1, 0], getpos("'A"))
+ call assert_equal(['9'], getregion(getpos("'B"), getpos("'A"), {'type': 'v' }))
+ exe $':{anotherbuf}bwipe!'
+
+ #" using invalid buffer
+ call assert_equal([], getregion([10000, 10, 1, 0], [10000, 10, 1, 0]))
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ bwipe!
+
+ let lines =<< trim END
+ #" Selection in starts or ends in the middle of a multibyte character
+ new
+ call setline(1, [
+ \ "abcdefghijk\u00ab",
+ \ "\U0001f1e6\u00ab\U0001f1e7\u00ab\U0001f1e8\u00ab\U0001f1e9",
+ \ "1234567890"
+ \ ])
+ call cursor(1, 3)
+ call feedkeys("\<Esc>\<C-v>ljj", 'xt')
+ call assert_equal(['cd', "\u00ab ", '34'],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ call cursor(1, 4)
+ call feedkeys("\<Esc>\<C-v>ljj", 'xt')
+ call assert_equal(['de', "\U0001f1e7", '45'],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ call cursor(1, 5)
+ call feedkeys("\<Esc>\<C-v>jj", 'xt')
+ call assert_equal(['e', ' ', '5'],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>vj", 'xt')
+ call assert_equal(['abcdefghijk«', "\U0001f1e6"],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'v' }))
+
+ #" marks on multibyte chars
+ :set selection=exclusive
+ call setpos("'a", [0, 1, 11, 0])
+ call setpos("'b", [0, 2, 16, 0])
+ call setpos("'c", [0, 2, 0, 0])
+ call cursor(1, 1)
+ call assert_equal(['ghijk', '🇨«🇩'],
+ \ getregion(getpos("'a"), getpos("'b"), {'type': "\<c-v>" }))
+ call assert_equal(['k«', '🇦«🇧«🇨'],
+ \ getregion(getpos("'a"), getpos("'b"), {'type': 'v' }))
+ call assert_equal(['k«'],
+ \ getregion(getpos("'a"), getpos("'c"), {'type': 'v' }))
+
+ #" use inclusive selection, although 'selection' is exclusive
+ call setpos("'a", [0, 1, 11, 0])
+ call setpos("'b", [0, 1, 1, 0])
+ call assert_equal(['abcdefghijk'],
+ \ getregion(getpos("'a"), getpos("'b"),
+ \ {'type': "\<c-v>", 'exclusive': v:false }))
+ call assert_equal(['abcdefghij'],
+ \ getregion(getpos("'a"), getpos("'b"),
+ \ {'type': "\<c-v>", 'exclusive': v:true }))
+ call assert_equal(['abcdefghijk'],
+ \ getregion(getpos("'a"), getpos("'b"),
+ \ {'type': 'v', 'exclusive': 0 }))
+ call assert_equal(['abcdefghij'],
+ \ getregion(getpos("'a"), getpos("'b"),
+ \ {'type': 'v', 'exclusive': 1 }))
+ call assert_equal(['abcdefghijk«'],
+ \ getregion(getpos("'a"), getpos("'b"),
+ \ {'type': 'V', 'exclusive': 0 }))
+ call assert_equal(['abcdefghijk«'],
+ \ getregion(getpos("'a"), getpos("'b"),
+ \ {'type': 'V', 'exclusive': 1 }))
+ :set selection&
+ END
+ call CheckLegacyAndVim9Success(lines)
+
+ bwipe!
+
+ let lines =<< trim END
+ #" Exclusive selection
+ new
+ set selection=exclusive
+ call setline(1, ["a\tc", "x\tz", '', ''])
+ call cursor(1, 1)
+ call feedkeys("\<Esc>v2l", 'xt')
+ call assert_equal(["a\t"],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'v' }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>v$G", 'xt')
+ call assert_equal(["a\tc", "x\tz", ''],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'v' }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>v$j", 'xt')
+ call assert_equal(["a\tc", "x\tz"],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'v' }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>\<C-v>$j", 'xt')
+ call assert_equal(["a\tc", "x\tz"],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>\<C-v>$G", 'xt')
+ call assert_equal(["a", "x", '', ''],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>wv2j", 'xt')
+ call assert_equal(["c", "x\tz"],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'v' }))
+ set selection&
+
+ #" Exclusive selection 2
+ new
+ call setline(1, ["a\tc", "x\tz", '', ''])
+ call cursor(1, 1)
+ call feedkeys("\<Esc>v2l", 'xt')
+ call assert_equal(["a\t"],
+ \ getregion(getpos('v'), getpos('.'), {'exclusive': v:true }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>v$G", 'xt')
+ call assert_equal(["a\tc", "x\tz", ''],
+ \ getregion(getpos('v'), getpos('.'), {'exclusive': v:true }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>v$j", 'xt')
+ call assert_equal(["a\tc", "x\tz"],
+ \ getregion(getpos('v'), getpos('.'), {'exclusive': v:true }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>\<C-v>$j", 'xt')
+ call assert_equal(["a\tc", "x\tz"],
+ \ getregion(getpos('v'), getpos('.'),
+ \ {'exclusive': v:true, 'type': "\<C-v>" }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>\<C-v>$G", 'xt')
+ call assert_equal(["a", "x", '', ''],
+ \ getregion(getpos('v'), getpos('.'),
+ \ {'exclusive': v:true, 'type': "\<C-v>" }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>wv2j", 'xt')
+ call assert_equal(["c", "x\tz"],
+ \ getregion(getpos('v'), getpos('.'), {'exclusive': v:true }))
+
+ #" virtualedit
+ set selection=exclusive
+ set virtualedit=all
+ call cursor(1, 1)
+ call feedkeys("\<Esc>2lv2lj", 'xt')
+ call assert_equal([' c', 'x '],
+ \ getregion(getpos('v'), getpos('.'), {'type': 'v' }))
+ call cursor(1, 1)
+ call feedkeys("\<Esc>2l\<C-v>2l2j", 'xt')
+ call assert_equal([' ', ' ', ' '],
+ \ getregion(getpos('v'), getpos('.'), {'type': "\<C-v>" }))
+ set virtualedit&
+ set selection&
+
+ bwipe!
+ END
+ call CheckLegacyAndVim9Success(lines)
+endfunc
+
+func Test_getregion_invalid_buf()
+ new
+ help
+ call cursor(5, 7)
+ norm! mA
+ call cursor(5, 18)
+ norm! mB
+ call assert_equal(['Move around:'], getregion(getpos("'A"), getpos("'B")))
+ " close the help window
+ q
+ call assert_equal([], getregion(getpos("'A"), getpos("'B")))
+ bwipe!
+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 152d1bacc7..da1711a0a1 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -113,6 +113,64 @@ func Test_window_quit()
bw Xa Xb
endfunc
+func Test_window_curwin_not_prevwin()
+ botright split
+ call assert_equal(2, winnr())
+ call assert_equal(1, winnr('#'))
+ quit
+ call assert_equal(1, winnr())
+ call assert_equal(0, winnr('#'))
+
+ botright split
+ botright split
+ call assert_equal(3, winnr())
+ call assert_equal(2, winnr('#'))
+ 1quit
+ call assert_equal(2, winnr())
+ call assert_equal(1, winnr('#'))
+
+ botright split
+ call assert_equal(1, tabpagenr())
+ call assert_equal(3, winnr())
+ call assert_equal(2, winnr('#'))
+ wincmd T
+ call assert_equal(2, tabpagenr())
+ call assert_equal(1, winnr())
+ call assert_equal(0, winnr('#'))
+ tabfirst
+ call assert_equal(1, tabpagenr())
+ call assert_equal(2, winnr())
+ call assert_equal(0, winnr('#'))
+
+ tabonly
+ botright split
+ wincmd t
+ wincmd p
+ call assert_equal(3, winnr())
+ call assert_equal(1, winnr('#'))
+ quit
+ call assert_equal(2, winnr())
+ call assert_equal(1, winnr('#'))
+
+ botright split
+ wincmd t
+ wincmd p
+ call assert_equal(1, tabpagenr())
+ call assert_equal(3, winnr())
+ call assert_equal(1, winnr('#'))
+ wincmd T
+ call assert_equal(2, tabpagenr())
+ call assert_equal(1, winnr())
+ call assert_equal(0, winnr('#'))
+ tabfirst
+ call assert_equal(1, tabpagenr())
+ call assert_equal(2, winnr())
+ call assert_equal(1, winnr('#'))
+
+ tabonly
+ only
+endfunc
+
func Test_window_horizontal_split()
call assert_equal(1, winnr('$'))
3wincmd s
diff --git a/test/old/testdir/vim9.vim b/test/old/testdir/vim9.vim
index 825f01c9d6..218fab6c5e 100644
--- a/test/old/testdir/vim9.vim
+++ b/test/old/testdir/vim9.vim
@@ -2,6 +2,10 @@
" Use a different file name for each run.
let s:sequence = 1
+func CheckDefSuccess(lines)
+ return
+endfunc
+
func CheckDefFailure(lines, error, lnum = -3)
return
endfunc
@@ -42,6 +46,49 @@ func CheckScriptSuccess(lines)
endtry
endfunc
+" :source a list of "lines" and check whether it fails with "error"
+func CheckSourceFailure(lines, error, lnum = -3)
+ if get(a:lines, 0, '') ==# 'vim9script'
+ return
+ endif
+ new
+ call setline(1, a:lines)
+ try
+ call assert_fails('source', a:error, a:lines, a:lnum)
+ finally
+ bw!
+ endtry
+endfunc
+
+" :source a list of "lines" and check whether it fails with the list of
+" "errors"
+func CheckSourceFailureList(lines, errors, lnum = -3)
+ if get(a:lines, 0, '') ==# 'vim9script'
+ return
+ endif
+ new
+ call setline(1, a:lines)
+ try
+ call assert_fails('source', a:errors, a:lines, a:lnum)
+ finally
+ bw!
+ endtry
+endfunc
+
+" :source a list of "lines" and check whether it succeeds
+func CheckSourceSuccess(lines)
+ if get(a:lines, 0, '') ==# 'vim9script'
+ return
+ endif
+ new
+ call setline(1, a:lines)
+ try
+ :source
+ finally
+ bw!
+ endtry
+endfunc
+
func CheckDefAndScriptSuccess(lines)
return
endfunc