mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	test: check that TextChangedT cannot delete terminal buffer
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
local luv = require('luv')
 | 
			
		||||
local helpers = require('test.functional.helpers')(after_each)
 | 
			
		||||
local thelpers = require('test.functional.terminal.helpers')
 | 
			
		||||
 | 
			
		||||
local clear, command, nvim, testprg =
 | 
			
		||||
  helpers.clear, helpers.command, helpers.nvim, helpers.testprg
 | 
			
		||||
@@ -8,6 +9,7 @@ local eval, eq, neq, retry =
 | 
			
		||||
local matches = helpers.matches
 | 
			
		||||
local ok = helpers.ok
 | 
			
		||||
local feed = helpers.feed
 | 
			
		||||
local meths = helpers.meths
 | 
			
		||||
local pcall_err = helpers.pcall_err
 | 
			
		||||
local assert_alive = helpers.assert_alive
 | 
			
		||||
local skip = helpers.skip
 | 
			
		||||
@@ -162,3 +164,21 @@ it('autocmd TermEnter, TermLeave', function()
 | 
			
		||||
    },
 | 
			
		||||
    eval('g:evs'))
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
describe('autocmd TextChangedT', function()
 | 
			
		||||
  clear()
 | 
			
		||||
  local screen = thelpers.screen_setup()
 | 
			
		||||
 | 
			
		||||
  it('works', function()
 | 
			
		||||
    command('autocmd TextChangedT * ++once let g:called = 1')
 | 
			
		||||
    thelpers.feed_data('a')
 | 
			
		||||
    retry(nil, nil, function() eq(1, meths.get_var('called')) end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('cannot delete terminal buffer', function()
 | 
			
		||||
    command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
 | 
			
		||||
    thelpers.feed_data('a')
 | 
			
		||||
    screen:expect({any = 'E937: '})
 | 
			
		||||
    matches('^E937: Attempt to delete a buffer that is in use: term://', meths.get_vvar('errmsg'))
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 
 | 
			
		||||
@@ -413,14 +413,6 @@ describe('on_lines does not emit out-of-bounds line indexes when', function()
 | 
			
		||||
    feed_command('bdelete!')
 | 
			
		||||
    eq('', exec_lua([[return _G.cb_error]]))
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('runs TextChangedT event', function()
 | 
			
		||||
    meths.set_var('called', 0)
 | 
			
		||||
    command('autocmd TextChangedT * ++once let g:called = 1')
 | 
			
		||||
    feed_command('terminal')
 | 
			
		||||
    feed('iaa')
 | 
			
		||||
    eq(1, meths.get_var('called'))
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
it('terminal truncates number of composing characters to 5', function()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user