mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 05:05:00 -07:00
vim-patch:8.2.3885: arglist test fails
Problem: Arglist test fails.
Solution: Adjust for locking the arglist for ":all".
679140c56b
This commit is contained in:
parent
dcdb7dca6a
commit
824a31cd0d
@ -509,18 +509,14 @@ func Test_arglist_autocmd()
|
||||
new
|
||||
" redefine arglist; go to Xxx1
|
||||
next! Xxx1 Xxx2 Xxx3
|
||||
" open window for all args; Reading Xxx2 will change the arglist and the
|
||||
" third window will get Xxx1:
|
||||
" win 1: Xxx1
|
||||
" win 2: Xxx2
|
||||
" win 3: Xxx1
|
||||
all
|
||||
" open window for all args; Reading Xxx2 will try to change the arglist and
|
||||
" that will fail
|
||||
call assert_fails("all", "E1156:")
|
||||
call assert_equal('test file Xxx1', getline(1))
|
||||
wincmd w
|
||||
wincmd w
|
||||
call assert_equal('test file Xxx1', getline(1))
|
||||
rewind
|
||||
call assert_equal('test file Xxx2', getline(1))
|
||||
wincmd w
|
||||
call assert_equal('test file Xxx3', getline(1))
|
||||
|
||||
autocmd! BufReadPost Xxx2
|
||||
enew! | only
|
||||
@ -610,7 +606,7 @@ endfunc
|
||||
func Test_clear_arglist_in_all()
|
||||
n 0 00 000 0000 00000 000000
|
||||
au! * 0 n 0
|
||||
all
|
||||
call assert_fails("all", "E1156")
|
||||
au! *
|
||||
endfunc
|
||||
|
||||
|
@ -1,85 +0,0 @@
|
||||
-- Test for autocommand that redefines the argument list, when doing ":all".
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||
local command, dedent, eq = helpers.command, helpers.dedent, helpers.eq
|
||||
local curbuf_contents = helpers.curbuf_contents
|
||||
local poke_eventloop = helpers.poke_eventloop
|
||||
|
||||
describe('argument list', function()
|
||||
setup(clear)
|
||||
|
||||
it('is working', function()
|
||||
insert([[
|
||||
start of test file Xxx
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
end of test file Xxx]])
|
||||
poke_eventloop()
|
||||
|
||||
command('au BufReadPost Xxx2 next Xxx2 Xxx1')
|
||||
command('/^start of')
|
||||
|
||||
-- Write test file Xxx1
|
||||
feed('A1<Esc>:.,/end of/w! Xxx1<cr>')
|
||||
|
||||
-- Write test file Xxx2
|
||||
feed('$r2:.,/end of/w! Xxx2<cr>')
|
||||
|
||||
-- Write test file Xxx3
|
||||
feed('$r3:.,/end of/w! Xxx3<cr>')
|
||||
poke_eventloop()
|
||||
|
||||
-- Redefine arglist; go to Xxx1
|
||||
command('next! Xxx1 Xxx2 Xxx3')
|
||||
|
||||
-- Open window for all args
|
||||
command('all')
|
||||
|
||||
-- Write contents of Xxx1
|
||||
command('%yank A')
|
||||
|
||||
-- Append contents of last window (Xxx1)
|
||||
feed('')
|
||||
poke_eventloop()
|
||||
command('%yank A')
|
||||
|
||||
-- should now be in Xxx2
|
||||
command('rew')
|
||||
|
||||
-- Append contents of Xxx2
|
||||
command('%yank A')
|
||||
|
||||
command('%d')
|
||||
command('0put=@a')
|
||||
command('$d')
|
||||
|
||||
eq(dedent([[
|
||||
start of test file Xxx1
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
end of test file Xxx
|
||||
start of test file Xxx1
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
end of test file Xxx
|
||||
start of test file Xxx2
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
this is a test
|
||||
end of test file Xxx]]), curbuf_contents())
|
||||
end)
|
||||
|
||||
teardown(function()
|
||||
os.remove('Xxx1')
|
||||
os.remove('Xxx2')
|
||||
os.remove('Xxx3')
|
||||
end)
|
||||
end)
|
@ -3,7 +3,6 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
|
||||
local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq
|
||||
local expect_exit = helpers.expect_exit
|
||||
local feed = helpers.feed
|
||||
local pcall_err = helpers.pcall_err
|
||||
@ -11,233 +10,6 @@ local pcall_err = helpers.pcall_err
|
||||
describe('argument list commands', function()
|
||||
before_each(clear)
|
||||
|
||||
local function init_abc()
|
||||
command('args a b c')
|
||||
command('next')
|
||||
end
|
||||
|
||||
local function reset_arglist()
|
||||
command('arga a | %argd')
|
||||
end
|
||||
|
||||
local function assert_fails(cmd, err)
|
||||
neq(nil, exc_exec(cmd):find(err))
|
||||
end
|
||||
|
||||
it('test that argidx() works', function()
|
||||
command('args a b c')
|
||||
command('last')
|
||||
eq(2, eval('argidx()'))
|
||||
command('%argdelete')
|
||||
eq(0, eval('argidx()'))
|
||||
|
||||
command('args a b c')
|
||||
eq(0, eval('argidx()'))
|
||||
command('next')
|
||||
eq(1, eval('argidx()'))
|
||||
command('next')
|
||||
eq(2, eval('argidx()'))
|
||||
command('1argdelete')
|
||||
eq(1, eval('argidx()'))
|
||||
command('1argdelete')
|
||||
eq(0, eval('argidx()'))
|
||||
command('1argdelete')
|
||||
eq(0, eval('argidx()'))
|
||||
end)
|
||||
|
||||
it('test that argadd() works', function()
|
||||
command('%argdelete')
|
||||
command('argadd a b c')
|
||||
eq(0, eval('argidx()'))
|
||||
|
||||
command('%argdelete')
|
||||
command('argadd a')
|
||||
eq(0, eval('argidx()'))
|
||||
command('argadd b c d')
|
||||
eq(0, eval('argidx()'))
|
||||
|
||||
init_abc()
|
||||
command('argadd x')
|
||||
eq({'a', 'b', 'x', 'c'}, eval('argv()'))
|
||||
eq(1, eval('argidx()'))
|
||||
|
||||
init_abc()
|
||||
command('0argadd x')
|
||||
eq({'x', 'a', 'b', 'c'}, eval('argv()'))
|
||||
eq(2, eval('argidx()'))
|
||||
|
||||
init_abc()
|
||||
command('1argadd x')
|
||||
eq({'a', 'x', 'b', 'c'}, eval('argv()'))
|
||||
eq(2, eval('argidx()'))
|
||||
|
||||
init_abc()
|
||||
command('$argadd x')
|
||||
eq({'a', 'b', 'c', 'x'}, eval('argv()'))
|
||||
eq(1, eval('argidx()'))
|
||||
|
||||
init_abc()
|
||||
command('$argadd x')
|
||||
command('+2argadd y')
|
||||
eq({'a', 'b', 'c', 'x', 'y'}, eval('argv()'))
|
||||
eq(1, eval('argidx()'))
|
||||
|
||||
command('%argd')
|
||||
command('edit d')
|
||||
command('arga')
|
||||
eq(1, eval('len(argv())'))
|
||||
eq('d', eval('get(argv(), 0, "")'))
|
||||
|
||||
command('%argd')
|
||||
command('new')
|
||||
command('arga')
|
||||
eq(0, eval('len(argv())'))
|
||||
end)
|
||||
|
||||
it('test for 0argadd and 0argedit', function()
|
||||
reset_arglist()
|
||||
|
||||
command('arga a b c d')
|
||||
command('2argu')
|
||||
command('0arga added')
|
||||
eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()'))
|
||||
|
||||
command('%argd')
|
||||
command('arga a b c d')
|
||||
command('2argu')
|
||||
command('0arge edited')
|
||||
eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()'))
|
||||
|
||||
command('2argu')
|
||||
command('arga third')
|
||||
eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()'))
|
||||
end)
|
||||
|
||||
it('test for argc()', function()
|
||||
reset_arglist()
|
||||
eq(0, eval('argc()'))
|
||||
command('argadd a b')
|
||||
eq(2, eval('argc()'))
|
||||
end)
|
||||
|
||||
it('test for arglistid()', function()
|
||||
reset_arglist()
|
||||
command('arga a b')
|
||||
eq(0, eval('arglistid()'))
|
||||
command('split')
|
||||
command('arglocal')
|
||||
eq(1, eval('arglistid()'))
|
||||
command('tabnew | tabfirst')
|
||||
eq(0, eval('arglistid(2)'))
|
||||
eq(1, eval('arglistid(1, 1)'))
|
||||
eq(0, eval('arglistid(2, 1)'))
|
||||
eq(1, eval('arglistid(1, 2)'))
|
||||
command('tabonly | only | enew!')
|
||||
command('argglobal')
|
||||
eq(0, eval('arglistid()'))
|
||||
end)
|
||||
|
||||
it('test for argv()', function()
|
||||
reset_arglist()
|
||||
eq({}, eval('argv()'))
|
||||
eq('', eval('argv(2)'))
|
||||
command('argadd a b c d')
|
||||
eq('c', eval('argv(2)'))
|
||||
end)
|
||||
|
||||
it('test for :argedit command', function()
|
||||
reset_arglist()
|
||||
command('argedit a')
|
||||
eq({'a'}, eval('argv()'))
|
||||
eq('a', eval('expand("%:t")'))
|
||||
command('argedit b')
|
||||
eq({'a', 'b'}, eval('argv()'))
|
||||
eq('b', eval('expand("%:t")'))
|
||||
command('argedit a')
|
||||
eq({'a', 'b', 'a'}, eval('argv()'))
|
||||
eq('a', eval('expand("%:t")'))
|
||||
command('argedit c')
|
||||
eq({'a', 'b', 'a', 'c'}, eval('argv()'))
|
||||
command('0argedit x')
|
||||
eq({'x', 'a', 'b', 'a', 'c'}, eval('argv()'))
|
||||
command('set nohidden')
|
||||
command('enew! | set modified')
|
||||
assert_fails('argedit y', 'E37:')
|
||||
command('argedit! y')
|
||||
eq({'x', 'y', 'y', 'a', 'b', 'a', 'c'}, eval('argv()'))
|
||||
command('set hidden')
|
||||
command('%argd')
|
||||
command('argedit a b')
|
||||
eq({'a', 'b'}, eval('argv()'))
|
||||
end)
|
||||
|
||||
it('test for :argdelete command', function()
|
||||
reset_arglist()
|
||||
command('args aa a aaa b bb')
|
||||
command('argdelete a*')
|
||||
eq({'b', 'bb'}, eval('argv()'))
|
||||
eq('aa', eval('expand("%:t")'))
|
||||
command('last')
|
||||
command('argdelete %')
|
||||
eq({'b'}, eval('argv()'))
|
||||
assert_fails('argdelete', 'E610:')
|
||||
assert_fails('1,100argdelete', 'E16:')
|
||||
reset_arglist()
|
||||
command('args a b c d')
|
||||
command('next')
|
||||
command('argdel')
|
||||
eq({'a', 'c', 'd'}, eval('argv()'))
|
||||
command('%argdel')
|
||||
end)
|
||||
|
||||
it('test for the :next, :prev, :first, :last, :rewind commands', function()
|
||||
reset_arglist()
|
||||
command('args a b c d')
|
||||
command('last')
|
||||
eq(3, eval('argidx()'))
|
||||
assert_fails('next', 'E165:')
|
||||
command('prev')
|
||||
eq(2, eval('argidx()'))
|
||||
command('Next')
|
||||
eq(1, eval('argidx()'))
|
||||
command('first')
|
||||
eq(0, eval('argidx()'))
|
||||
assert_fails('prev', 'E164:')
|
||||
command('3next')
|
||||
eq(3, eval('argidx()'))
|
||||
command('rewind')
|
||||
eq(0, eval('argidx()'))
|
||||
command('%argd')
|
||||
end)
|
||||
|
||||
it('test for autocommand that redefines the argument list, when doing ":all"', function()
|
||||
command('autocmd BufReadPost Xxx2 next Xxx2 Xxx1')
|
||||
command("call writefile(['test file Xxx1'], 'Xxx1')")
|
||||
command("call writefile(['test file Xxx2'], 'Xxx2')")
|
||||
command("call writefile(['test file Xxx3'], 'Xxx3')")
|
||||
|
||||
command('new')
|
||||
-- redefine arglist; go to Xxx1
|
||||
command('next! Xxx1 Xxx2 Xxx3')
|
||||
-- open window for all args
|
||||
command('all')
|
||||
eq('test file Xxx1', eval('getline(1)'))
|
||||
command('wincmd w')
|
||||
command('wincmd w')
|
||||
eq('test file Xxx1', eval('getline(1)'))
|
||||
-- should now be in Xxx2
|
||||
command('rewind')
|
||||
eq('test file Xxx2', eval('getline(1)'))
|
||||
|
||||
command('autocmd! BufReadPost Xxx2')
|
||||
command('enew! | only')
|
||||
command("call delete('Xxx1')")
|
||||
command("call delete('Xxx2')")
|
||||
command("call delete('Xxx3')")
|
||||
command('argdelete Xxx*')
|
||||
command('bwipe! Xxx1 Xxx2 Xxx3')
|
||||
end)
|
||||
|
||||
it('quitting Vim with unedited files in the argument list throws E173', function()
|
||||
command('set nomore')
|
||||
command('args a b c')
|
||||
|
Loading…
Reference in New Issue
Block a user