mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-03 17:24:29 +00:00 
			
		
		
		
	Merge pull request #13670 from janlazo/vim-8.2.2274
vim-patch:8.2.{456,458,461,470,2274,2277}
			
			
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
			
		||||
" Tests for various Ex commands.
 | 
			
		||||
 | 
			
		||||
source check.vim
 | 
			
		||||
 | 
			
		||||
func Test_ex_delete()
 | 
			
		||||
  new
 | 
			
		||||
  call setline(1, ['a', 'b', 'c'])
 | 
			
		||||
@@ -40,3 +42,81 @@ func Test_buffers_lastused()
 | 
			
		||||
  bwipeout bufb
 | 
			
		||||
  bwipeout bufc
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
" Test for the :confirm command dialog
 | 
			
		||||
func Test_confirm_cmd()
 | 
			
		||||
  CheckNotGui
 | 
			
		||||
  CheckRunVimInTerminal
 | 
			
		||||
  call writefile(['foo1'], 'foo')
 | 
			
		||||
  call writefile(['bar1'], 'bar')
 | 
			
		||||
  " Test for saving all the modified buffers
 | 
			
		||||
  let buf = RunVimInTerminal('', {'rows': 20})
 | 
			
		||||
  call term_sendkeys(buf, ":set nomore\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new foo\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'foo2')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new bar\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'bar2')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":wincmd b\n")
 | 
			
		||||
  call term_sendkeys(buf, ":confirm qall\n")
 | 
			
		||||
  call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, "A")
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
  call assert_equal(['foo2'], readfile('foo'))
 | 
			
		||||
  call assert_equal(['bar2'], readfile('bar'))
 | 
			
		||||
  " Test for discarding all the changes to modified buffers
 | 
			
		||||
  let buf = RunVimInTerminal('', {'rows': 20})
 | 
			
		||||
  call term_sendkeys(buf, ":set nomore\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new foo\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'foo3')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new bar\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'bar3')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":wincmd b\n")
 | 
			
		||||
  call term_sendkeys(buf, ":confirm qall\n")
 | 
			
		||||
  call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, "D")
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
  call assert_equal(['foo2'], readfile('foo'))
 | 
			
		||||
  call assert_equal(['bar2'], readfile('bar'))
 | 
			
		||||
  " Test for saving and discarding changes to some buffers
 | 
			
		||||
  let buf = RunVimInTerminal('', {'rows': 20})
 | 
			
		||||
  call term_sendkeys(buf, ":set nomore\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new foo\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'foo4')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new bar\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'bar4')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":wincmd b\n")
 | 
			
		||||
  call term_sendkeys(buf, ":confirm qall\n")
 | 
			
		||||
  call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, "N")
 | 
			
		||||
  call WaitForAssert({-> assert_match('\[Y\]es, (N)o, (C)ancel: ', term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, "Y")
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
  call assert_equal(['foo4'], readfile('foo'))
 | 
			
		||||
  call assert_equal(['bar2'], readfile('bar'))
 | 
			
		||||
 | 
			
		||||
  call delete('foo')
 | 
			
		||||
  call delete('bar')
 | 
			
		||||
endfunc
 | 
			
		||||
 | 
			
		||||
func Test_confirm_cmd_cancel()
 | 
			
		||||
  CheckNotGui
 | 
			
		||||
  CheckRunVimInTerminal
 | 
			
		||||
 | 
			
		||||
  " Test for closing a window with a modified buffer
 | 
			
		||||
  let buf = RunVimInTerminal('', {'rows': 20})
 | 
			
		||||
  call term_sendkeys(buf, ":set nomore\n")
 | 
			
		||||
  call term_sendkeys(buf, ":new\n")
 | 
			
		||||
  call term_sendkeys(buf, ":call setline(1, 'abc')\n")
 | 
			
		||||
  call term_sendkeys(buf, ":confirm close\n")
 | 
			
		||||
  call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
 | 
			
		||||
        \ term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, "C")
 | 
			
		||||
  call WaitForAssert({-> assert_equal('', term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, ":confirm close\n")
 | 
			
		||||
  call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
 | 
			
		||||
        \ term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call term_sendkeys(buf, "N")
 | 
			
		||||
  call WaitForAssert({-> assert_match('^ *0,0-1         All$',
 | 
			
		||||
        \ term_getline(buf, 20))}, 1000)
 | 
			
		||||
  call StopVimInTerminal(buf)
 | 
			
		||||
endfunc
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user