aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compat.lua12
-rw-r--r--test/functional/autocmd/cursormoved_spec.lua39
-rw-r--r--test/functional/core/startup_spec.lua13
-rw-r--r--test/functional/legacy/search_spec.lua42
-rw-r--r--test/functional/treesitter/parser_spec.lua101
-rw-r--r--test/functional/ui/linematch_spec.lua44
-rw-r--r--test/helpers.lua9
-rw-r--r--test/old/testdir/test_maparg.vim26
-rw-r--r--test/old/testdir/test_normal.vim38
-rw-r--r--test/old/testdir/test_quickfix.vim12
-rw-r--r--test/old/testdir/test_registers.vim26
-rw-r--r--test/old/testdir/test_search.vim27
-rw-r--r--test/old/testdir/test_undo.vim47
13 files changed, 380 insertions, 56 deletions
diff --git a/test/compat.lua b/test/compat.lua
deleted file mode 100644
index 2c9786d491..0000000000
--- a/test/compat.lua
+++ /dev/null
@@ -1,12 +0,0 @@
--- Lua 5.1 forward-compatibility layer.
--- For background see https://github.com/neovim/neovim/pull/9280
---
--- Reference the lua-compat-5.2 project for hints:
--- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/compat52/mstrict.lua
--- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/tests/test.lua
-
-local lua_version = _VERSION:sub(-3)
-
-if lua_version >= '5.2' then
- unpack = table.unpack -- luacheck: ignore 121 143
-end
diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua
index 64b63c3205..854e14b088 100644
--- a/test/functional/autocmd/cursormoved_spec.lua
+++ b/test/functional/autocmd/cursormoved_spec.lua
@@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
-local funcs = helpers.funcs
+local meths = helpers.meths
local source = helpers.source
local command = helpers.command
@@ -12,10 +12,10 @@ describe('CursorMoved', function()
it('is triggered after BufEnter when changing or splitting windows #11878 #12031', function()
source([[
- call setline(1, 'foo')
- let g:log = []
- autocmd BufEnter * let g:log += ['BufEnter' .. expand("<abuf>")]
- autocmd CursorMoved * let g:log += ['CursorMoved' .. expand("<abuf>")]
+ call setline(1, 'foo')
+ let g:log = []
+ autocmd BufEnter * let g:log += ['BufEnter' .. expand("<abuf>")]
+ autocmd CursorMoved * let g:log += ['CursorMoved' .. expand("<abuf>")]
]])
eq({}, eval('g:log'))
command('new')
@@ -24,23 +24,34 @@ describe('CursorMoved', function()
eq({'BufEnter2', 'CursorMoved2', 'BufEnter1', 'CursorMoved1'}, eval('g:log'))
end)
+ it('is not triggered by temporarily switching window', function()
+ source([[
+ let g:cursormoved = 0
+ vnew
+ autocmd CursorMoved * let g:cursormoved += 1
+ ]])
+ command('wincmd w | wincmd p')
+ eq(0, eval('g:cursormoved'))
+ end)
+
it("is not triggered by functions that don't change the window", function()
source([[
- let g:cursormoved = 0
- let g:buf = bufnr('%')
- vsplit foo
- autocmd CursorMoved * let g:cursormoved += 1
- call nvim_buf_set_lines(g:buf, 0, -1, v:true, ['aaa'])
+ let g:cursormoved = 0
+ let g:buf = bufnr('%')
+ vsplit foo
+ autocmd CursorMoved * let g:cursormoved += 1
]])
- eq({'aaa'}, funcs.nvim_buf_get_lines(eval('g:buf'), 0, -1, true))
+ meths.buf_set_lines(eval('g:buf'), 0, -1, true, {'aaa'})
+ eq(0, eval('g:cursormoved'))
+ eq({'aaa'}, meths.buf_get_lines(eval('g:buf'), 0, -1, true))
eq(0, eval('g:cursormoved'))
end)
it("is not triggered by cursor movement prior to first CursorMoved instantiation", function()
source([[
- let g:cursormoved = 0
- autocmd! CursorMoved
- autocmd CursorMoved * let g:cursormoved += 1
+ let g:cursormoved = 0
+ autocmd! CursorMoved
+ autocmd CursorMoved * let g:cursormoved += 1
]])
eq(0, eval('g:cursormoved'))
end)
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index fb30ddebb9..94ec3d4907 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -41,6 +41,19 @@ describe('startup', function()
ok(string.find(alter_slashes(meths.get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true) == nil)
end)
+ it('prevents remote UI infinite loop', function()
+ clear()
+ local screen
+ screen = Screen.new(84, 3)
+ screen:attach()
+ funcs.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' })
+ screen:expect([[
+ ^Cannot attach UI of :terminal child to its parent. (Unset $NVIM to skip this check) |
+ |
+ |
+ ]])
+ end)
+
it('--startuptime', function()
local testfile = 'Xtest_startuptime'
finally(function()
diff --git a/test/functional/legacy/search_spec.lua b/test/functional/legacy/search_spec.lua
index 4228940eda..25620f5262 100644
--- a/test/functional/legacy/search_spec.lua
+++ b/test/functional/legacy/search_spec.lua
@@ -642,7 +642,7 @@ describe('search cmdline', function()
end)
-- oldtest: Test_incsearch_substitute_dump2()
- it('detects empty pattern properly vim-patch:8.2.2295', function()
+ it('incsearch detects empty pattern properly vim-patch:8.2.2295', function()
screen:try_resize(70, 6)
exec([[
set incsearch hlsearch scrolloff=0
@@ -675,6 +675,46 @@ describe('search cmdline', function()
:1,5s/\v|^ |
]])
end)
+
+ -- oldtest: Test_incsearch_restore_view()
+ it('incsearch restores viewport', function()
+ screen:try_resize(20, 6)
+ exec([[
+ set incsearch nohlsearch
+ setlocal scrolloff=0 smoothscroll
+ call setline(1, [join(range(25), ' '), '', '', '', '', 'xxx'])
+ call feedkeys("2\<C-E>", 't')
+ ]])
+ local s = [[
+ {tilde:<<<} 18 19 20 21 22 2|
+ ^3 24 |
+ |
+ |
+ |
+ |
+ ]]
+ screen:expect(s)
+ feed('/xx')
+ screen:expect([[
+ |
+ |
+ |
+ |
+ {inc:xx}x |
+ /xx^ |
+ ]])
+ feed('x')
+ screen:expect([[
+ |
+ |
+ |
+ |
+ {inc:xxx} |
+ /xxx^ |
+ ]])
+ feed('<Esc>')
+ screen:expect(s)
+ end)
end)
describe('Search highlight', function()
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index da84f435c9..ae3b0483c5 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
+local dedent = helpers.dedent
local eq = helpers.eq
local insert = helpers.insert
local exec_lua = helpers.exec_lua
@@ -8,10 +9,13 @@ local pcall_err = helpers.pcall_err
local feed = helpers.feed
local is_os = helpers.is_os
-before_each(clear)
-
describe('treesitter parser API', function()
- clear()
+ before_each(function()
+ clear()
+ exec_lua[[
+ vim.g.__ts_debug = 1
+ ]]
+ end)
it('parses buffer', function()
insert([[
@@ -502,22 +506,12 @@ end]]
local root = parser:parse()[1]:root()
parser:set_included_regions({{root:child(0)}})
parser:invalidate()
- return { parser:parse()[1]:root():range() }
+ return { parser:parse(true)[1]:root():range() }
]]
eq({0, 0, 18, 1}, res2)
- local range = exec_lua [[
- local res = {}
- for _, region in ipairs(parser:included_regions()) do
- for _, node in ipairs(region) do
- table.insert(res, {node:range()})
- end
- end
- return res
- ]]
-
- eq(range, { { 0, 0, 18, 1 } })
+ eq({ { { 0, 0, 0, 18, 1, 512 } } }, exec_lua [[ return parser:included_regions() ]])
local range_tbl = exec_lua [[
parser:set_included_regions { { { 0, 0, 17, 1 } } }
@@ -542,7 +536,7 @@ end]]
parser:set_included_regions({nodes})
- local root = parser:parse()[1]:root()
+ local root = parser:parse(true)[1]:root()
local res = {}
for i=0,(root:named_child_count() - 1) do
@@ -641,6 +635,7 @@ int x = INT_MAX;
parser = vim.treesitter.get_parser(0, "c", {
injections = {
c = "(preproc_def (preproc_arg) @c) (preproc_function_def value: (preproc_arg) @c)"}})
+ parser:parse(true)
]])
eq("table", exec_lua("return type(parser:children().c)"))
@@ -673,6 +668,7 @@ int x = INT_MAX;
parser = vim.treesitter.get_parser(0, "c", {
injections = {
c = "(preproc_def (preproc_arg) @c @combined) (preproc_function_def value: (preproc_arg) @c @combined)"}})
+ parser:parse(true)
]])
eq("table", exec_lua("return type(parser:children().c)"))
@@ -713,6 +709,7 @@ int x = INT_MAX;
injections = {
c = "(preproc_def ((preproc_arg) @_c (#inject-clang! @_c)))" ..
"(preproc_function_def value: ((preproc_arg) @_a (#inject-clang! @_a)))"}})
+ parser:parse(true)
]=])
eq("table", exec_lua("return type(parser:children().c)"))
@@ -760,6 +757,7 @@ int x = INT_MAX;
parser = vim.treesitter.get_parser(0, "c", {
injections = {
c = "(preproc_def ((preproc_arg) @c (#offset! @c 0 2 0 -1))) (preproc_function_def value: (preproc_arg) @c)"}})
+ parser:parse(true)
]])
eq("table", exec_lua("return type(parser:children().c)"))
@@ -783,7 +781,7 @@ int x = INT_MAX;
return list
]]
- eq({ 'gsub!', 'inject-language!', 'offset!', 'set!', 'trim!' }, res_list)
+ eq({ 'gsub!', 'offset!', 'set!', 'trim!' }, res_list)
end)
end)
end)
@@ -800,6 +798,7 @@ int x = INT_MAX;
local result = exec_lua([[
parser = vim.treesitter.get_parser(0, "c", {
injections = { c = "(preproc_def (preproc_arg) @c)"}})
+ parser:parse(true)
local sub_tree = parser:language_for_range({1, 18, 1, 19})
@@ -951,7 +950,7 @@ int x = INT_MAX;
local r = exec_lua([[
local parser = vim.treesitter.get_string_parser(..., 'lua')
- parser:parse()
+ parser:parse(true)
local ranges = {}
parser:for_each_tree(function(tstree, tree)
ranges[tree:lang()] = { tstree:root():range(true) }
@@ -997,7 +996,7 @@ int x = INT_MAX;
vimdoc = "((codeblock (language) @injection.language (code) @injection.content))"
}
})
- parser1:parse()
+ parser1:parse(true)
]]
eq(0, exec_lua("return #vim.tbl_keys(parser1:children())"))
@@ -1008,7 +1007,7 @@ int x = INT_MAX;
vimdoc = "((codeblock (language) @injection.language (code) @injection.content) (#set! injection.include-children))"
}
})
- parser2:parse()
+ parser2:parse(true)
]]
eq(1, exec_lua("return #vim.tbl_keys(parser2:children())"))
@@ -1016,4 +1015,66 @@ int x = INT_MAX;
end)
+ it("parsers injections incrementally", function()
+ insert(dedent[[
+ >lua
+ local a = {}
+ <
+
+ >lua
+ local b = {}
+ <
+
+ >lua
+ local c = {}
+ <
+
+ >lua
+ local d = {}
+ <
+
+ >lua
+ local e = {}
+ <
+
+ >lua
+ local f = {}
+ <
+
+ >lua
+ local g = {}
+ <
+ ]])
+
+ exec_lua [[
+ parser = require('vim.treesitter.languagetree').new(0, "vimdoc", {
+ injections = {
+ vimdoc = "((codeblock (language) @injection.language (code) @injection.content) (#set! injection.include-children))"
+ }
+ })
+ ]]
+
+ --- Do not parse injections by default
+ eq(0, exec_lua [[
+ parser:parse()
+ return #vim.tbl_keys(parser:children())
+ ]])
+
+ --- Only parse injections between lines 0, 2
+ eq(1, exec_lua [[
+ parser:parse({0, 2})
+ return #parser:children().lua:trees()
+ ]])
+
+ eq(2, exec_lua [[
+ parser:parse({2, 6})
+ return #parser:children().lua:trees()
+ ]])
+
+ eq(7, exec_lua [[
+ parser:parse(true)
+ return #parser:children().lua:trees()
+ ]])
+ end)
+
end)
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua
index 76197bc7e0..ef47ea7ed0 100644
--- a/test/functional/ui/linematch_spec.lua
+++ b/test/functional/ui/linematch_spec.lua
@@ -1178,4 +1178,48 @@ describe('regressions', function()
helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010)..'world' })
helpers.exec 'windo diffthis'
end)
+
+ it("properly computes filler lines for hunks bigger than linematch limit", function()
+ clear()
+ feed(':set diffopt+=linematch:10<cr>')
+ screen = Screen.new(100, 20)
+ screen:attach()
+ local lines = {}
+ for i = 0, 29 do
+ lines[#lines + 1] = tostring(i)
+ end
+ helpers.curbufmeths.set_lines(0, -1, false, lines)
+ helpers.exec 'vnew'
+ helpers.curbufmeths.set_lines(0, -1, false, { '00', '29' })
+ helpers.exec 'windo diffthis'
+ feed('<C-e>')
+ screen:expect{grid=[[
+ {1: }{2:------------------------------------------------}│{1: }{3:^1 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:2 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:3 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:4 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:5 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:6 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:7 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:8 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:9 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:10 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:11 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:12 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:13 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:14 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:15 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:16 }|
+ {1: }{2:------------------------------------------------}│{1: }{3:17 }|
+ {1: }29 │{1: }{3:18 }|
+ {4:[No Name] [+] }{5:[No Name] [+] }|
+ |
+ ]], attr_ids={
+ [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey};
+ [2] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1};
+ [3] = {background = Screen.colors.LightBlue};
+ [4] = {reverse = true};
+ [5] = {reverse = true, bold = true};
+ }}
+ end)
end)
diff --git a/test/helpers.lua b/test/helpers.lua
index 8f06311a3c..51114611ab 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -1,4 +1,3 @@
-require('test.compat')
local shared = vim
local assert = require('luassert')
local busted = require('busted')
@@ -570,21 +569,23 @@ function module.concat_tables(...)
end
--- @param str string
---- @param leave_indent? boolean
+--- @param leave_indent? integer
--- @return string
function module.dedent(str, leave_indent)
-- find minimum common indent across lines
- local indent = nil
+ local indent --- @type string?
for line in str:gmatch('[^\n]+') do
local line_indent = line:match('^%s+') or ''
if indent == nil or #line_indent < #indent then
indent = line_indent
end
end
- if indent == nil or #indent == 0 then
+
+ if not indent or #indent == 0 then
-- no minimum common indent
return str
end
+
local left_indent = (' '):rep(leave_indent or 0)
-- create a pattern for the indent
indent = indent:gsub('%s', '[ \t]')
diff --git a/test/old/testdir/test_maparg.vim b/test/old/testdir/test_maparg.vim
index 12670671dd..1837511990 100644
--- a/test/old/testdir/test_maparg.vim
+++ b/test/old/testdir/test_maparg.vim
@@ -322,8 +322,32 @@ func Test_map_restore()
nunmap <C-B>
endfunc
-" Test restoring the script context of a mapping
+" Test restoring an <SID> mapping
func Test_map_restore_sid()
+ func RestoreMap()
+ const d = maparg('<CR>', 'i', v:false, v:true)
+ iunmap <buffer> <CR>
+ call mapset('i', v:false, d)
+ endfunc
+
+ let mapscript =<< trim [CODE]
+ inoremap <silent><buffer> <SID>Return <C-R>=42<CR>
+ inoremap <script><buffer> <CR> <CR><SID>Return
+ [CODE]
+ call writefile(mapscript, 'Xmapscript', 'D')
+
+ new
+ source Xmapscript
+ inoremap <buffer> <C-B> <Cmd>call RestoreMap()<CR>
+ call feedkeys("i\<CR>\<*C-B>\<CR>", 'xt')
+ call assert_equal(['', '42', '42'], getline(1, '$'))
+
+ bwipe!
+ delfunc RestoreMap
+endfunc
+
+" Test restoring a mapping with a negative script ID
+func Test_map_restore_negative_sid()
let after =<< trim [CODE]
call assert_equal("\tLast set from --cmd argument",
\ execute('verbose nmap ,n')->trim()->split("\n")[-1])
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index 23baebb78c..c8e78dcf93 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -4011,4 +4011,42 @@ func Test_normal_j_below_botline()
call StopVimInTerminal(buf)
endfunc
+" Test for r (replace) command with CTRL_V and CTRL_Q
+func Test_normal_r_ctrl_v_cmd()
+ new
+ call append(0, 'This is a simple test: abcd')
+ exe "norm! 1gg$r\<C-V>\<C-V>"
+ call assert_equal(['This is a simple test: abc', ''], getline(1,'$'))
+ exe "norm! 1gg$hr\<C-Q>\<C-Q>"
+ call assert_equal(['This is a simple test: ab', ''], getline(1,'$'))
+ exe "norm! 1gg$2hr\<C-V>x7e"
+ call assert_equal(['This is a simple test: a~', ''], getline(1,'$'))
+ exe "norm! 1gg$3hr\<C-Q>x7e"
+ call assert_equal(['This is a simple test: ~~', ''], getline(1,'$'))
+
+ if &encoding == 'utf-8'
+ exe "norm! 1gg$4hr\<C-V>u20ac"
+ call assert_equal(['This is a simple test:€~~', ''], getline(1,'$'))
+ exe "norm! 1gg$5hr\<C-Q>u20ac"
+ call assert_equal(['This is a simple test€€~~', ''], getline(1,'$'))
+ exe "norm! 1gg0R\<C-V>xff WAS \<esc>"
+ call assert_equal(['ÿ WAS a simple test€€~~', ''], getline(1,'$'))
+ exe "norm! 1gg0elR\<C-Q>xffNOT\<esc>"
+ call assert_equal(['ÿ WASÿNOT simple test€€~~', ''], getline(1,'$'))
+ endif
+
+ call setline(1, 'This is a simple test: abcd')
+ exe "norm! 1gg$gr\<C-V>\<C-V>"
+ call assert_equal(['This is a simple test: abc', ''], getline(1,'$'))
+ exe "norm! 1gg$hgr\<C-Q>\<C-Q>"
+ call assert_equal(['This is a simple test: ab ', ''], getline(1,'$'))
+ exe "norm! 1gg$2hgr\<C-V>x7e"
+ call assert_equal(['This is a simple test: a~ ', ''], getline(1,'$'))
+ exe "norm! 1gg$3hgr\<C-Q>x7e"
+ call assert_equal(['This is a simple test: ~~ ', ''], getline(1,'$'))
+
+ " clean up
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_quickfix.vim b/test/old/testdir/test_quickfix.vim
index 6378ee8770..e61da49584 100644
--- a/test/old/testdir/test_quickfix.vim
+++ b/test/old/testdir/test_quickfix.vim
@@ -1649,13 +1649,23 @@ func SetXlistTests(cchar, bnum)
call s:setup_commands(a:cchar)
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 1},
- \ {'bufnr': a:bnum, 'lnum': 2, 'end_lnum': 3, 'col': 4, 'end_col': 5}])
+ \ {'bufnr': a:bnum, 'lnum': 2, 'end_lnum': 3, 'col': 4, 'end_col': 5, 'user_data': {'6': [7, 8]}}])
let l = g:Xgetlist()
call assert_equal(2, len(l))
call assert_equal(2, l[1].lnum)
call assert_equal(3, l[1].end_lnum)
call assert_equal(4, l[1].col)
call assert_equal(5, l[1].end_col)
+ call assert_equal({'6': [7, 8]}, l[1].user_data)
+
+ " Test that user_data is garbage collected
+ call g:Xsetlist([{'user_data': ['high', 5]},
+ \ {'user_data': {'this': [7, 'eight'], 'is': ['a', 'dictionary']}}])
+ call test_garbagecollect_now()
+ let l = g:Xgetlist()
+ call assert_equal(2, len(l))
+ call assert_equal(['high', 5], l[0].user_data)
+ call assert_equal({'this': [7, 'eight'], 'is': ['a', 'dictionary']}, l[1].user_data)
Xnext
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a')
diff --git a/test/old/testdir/test_registers.vim b/test/old/testdir/test_registers.vim
index 70dac535b4..01f9507916 100644
--- a/test/old/testdir/test_registers.vim
+++ b/test/old/testdir/test_registers.vim
@@ -758,8 +758,9 @@ func Test_record_in_select_mode()
bwipe!
endfunc
-" mapping that ends macro recording should be removed from recorded macro
+" A mapping that ends recording should be removed from the recorded register.
func Test_end_record_using_mapping()
+ new
call setline(1, 'aaa')
nnoremap s q
call feedkeys('safas', 'tx')
@@ -779,7 +780,10 @@ func Test_end_record_using_mapping()
bwipe!
endfunc
+" Starting a new recording should work immediately after replaying a recording
+" that ends with a <Nop> mapping or a character search.
func Test_end_reg_executing()
+ new
nnoremap s <Nop>
let @a = 's'
call feedkeys("@aqaq\<Esc>", 'tx')
@@ -797,5 +801,25 @@ func Test_end_reg_executing()
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()
+ CheckFeature timers
+
+ new
+ call setline(1, 'foo[blah]')
+ onoremap , k
+ call timer_start(10, {-> feedkeys(",bar\<Esc>q", 't')})
+ call feedkeys('qrct[', 'xt!')
+ call assert_equal(',bar[blah]', getline(1))
+ undo
+ call assert_equal('foo[blah]', getline(1))
+ call feedkeys('@r', 'xt!')
+ call assert_equal(',bar[blah]', getline(1))
+
+ ounmap ,
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_search.vim b/test/old/testdir/test_search.vim
index 37909d0afe..4a92ae34e4 100644
--- a/test/old/testdir/test_search.vim
+++ b/test/old/testdir/test_search.vim
@@ -1996,7 +1996,7 @@ func Test_incsearch_substitute_dump2()
\ 'endfor',
\ 'call setline(5, "abc|def")',
\ '3',
- \ ], 'Xis_subst_script2')
+ \ ], 'Xis_subst_script2', 'D')
let buf = RunVimInTerminal('-S Xis_subst_script2', {'rows': 9, 'cols': 70})
call term_sendkeys(buf, ':%s/\vabc|')
@@ -2011,7 +2011,30 @@ func Test_incsearch_substitute_dump2()
call StopVimInTerminal(buf)
- call delete('Xis_subst_script2')
+endfunc
+
+func Test_incsearch_restore_view()
+ CheckOption incsearch
+ CheckScreendump
+
+ let lines =<< trim [CODE]
+ set incsearch nohlsearch
+ setlocal scrolloff=0 smoothscroll
+ call setline(1, [join(range(25), ' '), '', '', '', '', 'xxx'])
+ call feedkeys("2\<C-E>", 't')
+ [CODE]
+ call writefile(lines, 'Xincsearch_restore_view', 'D')
+ let buf = RunVimInTerminal('-S Xincsearch_restore_view', {'rows': 6, 'cols': 20})
+
+ call VerifyScreenDump(buf, 'Test_incsearch_restore_view_01', {})
+ call term_sendkeys(buf, '/xx')
+ call VerifyScreenDump(buf, 'Test_incsearch_restore_view_02', {})
+ call term_sendkeys(buf, 'x')
+ call VerifyScreenDump(buf, 'Test_incsearch_restore_view_03', {})
+ call term_sendkeys(buf, "\<Esc>")
+ call VerifyScreenDump(buf, 'Test_incsearch_restore_view_01', {})
+
+ call StopVimInTerminal(buf)
endfunc
func Test_pattern_is_uppercase_smartcase()
diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim
index 4678a51d60..08a0ba4c39 100644
--- a/test/old/testdir/test_undo.vim
+++ b/test/old/testdir/test_undo.vim
@@ -93,6 +93,53 @@ func FillBuffer()
endfor
endfunc
+func Test_undotree_bufnr()
+ new
+ let buf1 = bufnr()
+
+ normal! Aabc
+ set ul=100
+
+ " Save undo tree without bufnr as ground truth for buffer 1
+ let d1 = undotree()
+
+ new
+ let buf2 = bufnr()
+
+ normal! Adef
+ set ul=100
+
+ normal! Aghi
+ set ul=100
+
+ " Save undo tree without bufnr as ground truth for buffer 2
+ let d2 = undotree()
+
+ " Check undotree() with bufnr argument
+ let d = undotree(buf1)
+ call assert_equal(d1, d)
+ call assert_notequal(d2, d)
+
+ let d = undotree(buf2)
+ call assert_notequal(d1, d)
+ call assert_equal(d2, d)
+
+ " Switch buffers and check again
+ wincmd p
+
+ let d = undotree(buf1)
+ call assert_equal(d1, d)
+
+ let d = undotree(buf2)
+ call assert_notequal(d1, d)
+ call assert_equal(d2, d)
+
+ " Drop created windows
+ set ul&
+ new
+ only!
+endfunc
+
func Test_global_local_undolevels()
new one
set undolevels=5