aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/autocmd
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/functional/autocmd')
-rw-r--r--test/functional/autocmd/autocmd_spec.lua24
-rw-r--r--test/functional/autocmd/completedone_spec.lua2
-rw-r--r--test/functional/autocmd/dirchanged_spec.lua9
-rw-r--r--test/functional/autocmd/focus_spec.lua8
-rw-r--r--test/functional/autocmd/termxx_spec.lua4
5 files changed, 33 insertions, 14 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index c62e4752e0..1b7275ebf6 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -160,7 +160,7 @@ describe('autocmd', function()
it('++once', function() -- :help autocmd-once
--
- -- ":autocmd ... ++once" executes its handler once, then removes the handler.
+ -- ":autocmd … ++once" executes its handler once, then removes the handler.
--
local expected = {
'Many1',
@@ -206,7 +206,7 @@ describe('autocmd', function()
)
--
- -- ":autocmd ... ++once" handlers can be deleted.
+ -- ":autocmd … ++once" handlers can be deleted.
--
expected = {}
command('let g:foo = []')
@@ -216,7 +216,7 @@ describe('autocmd', function()
eq(expected, eval('g:foo'))
--
- -- ":autocmd ... <buffer> ++once ++nested"
+ -- ":autocmd … <buffer> ++once ++nested"
--
expected = {
'OptionSet-Once',
@@ -250,6 +250,24 @@ describe('autocmd', function()
--- Autocommands ---]]),
fn.execute('autocmd Tabnew')
)
+
+ --
+ -- :autocmd does not recursively call ++once Lua handlers.
+ --
+ exec_lua [[vim.g.count = 0]]
+ eq(0, eval('g:count'))
+ exec_lua [[
+ vim.api.nvim_create_autocmd('User', {
+ once = true,
+ pattern = nil,
+ callback = function()
+ vim.g.count = vim.g.count + 1
+ vim.api.nvim_exec_autocmds('User', { pattern = nil })
+ end,
+ })
+ vim.api.nvim_exec_autocmds('User', { pattern = nil })
+ ]]
+ eq(1, eval('g:count'))
end)
it('internal `aucmd_win` window', function()
diff --git a/test/functional/autocmd/completedone_spec.lua b/test/functional/autocmd/completedone_spec.lua
index 33beb16db2..36dc73842d 100644
--- a/test/functional/autocmd/completedone_spec.lua
+++ b/test/functional/autocmd/completedone_spec.lua
@@ -32,7 +32,7 @@ describe('CompleteDone', function()
feed('<Esc>')
eq('cancel', eval('g:donereason'))
end)
- it('when overriden by another complete()', function()
+ it('when overridden by another complete()', function()
call('complete', call('col', '.'), { 'bar', 'baz' })
eq('cancel', eval('g:donereason'))
end)
diff --git a/test/functional/autocmd/dirchanged_spec.lua b/test/functional/autocmd/dirchanged_spec.lua
index 1cde0e0552..9b572df568 100644
--- a/test/functional/autocmd/dirchanged_spec.lua
+++ b/test/functional/autocmd/dirchanged_spec.lua
@@ -351,11 +351,10 @@ describe('autocmd DirChanged and DirChangedPre', function()
eq(2, eval('g:cdprecount'))
eq(2, eval('g:cdcount'))
- local status, err = pcall(function()
- request('nvim_set_current_dir', '/doesnotexist')
- end)
- eq(false, status)
- eq('Failed to change directory', string.match(err, ': (.*)'))
+ eq(
+ 'Vim:E344: Can\'t find directory "/doesnotexist" in cdpath',
+ t.pcall_err(request, 'nvim_set_current_dir', '/doesnotexist')
+ )
eq({ directory = '/doesnotexist', scope = 'global', changed_window = false }, eval('g:evpre'))
eq(3, eval('g:cdprecount'))
eq(2, eval('g:cdcount'))
diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua
index 7f6092bf48..177e8997cf 100644
--- a/test/functional/autocmd/focus_spec.lua
+++ b/test/functional/autocmd/focus_spec.lua
@@ -47,7 +47,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
screen:expect {
grid = [[
- {1: } |
+ ^ |
{4:~ }|*3
{5:[No Name] }|
|
@@ -57,7 +57,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
feed_command('edit ' .. path)
screen:expect {
grid = [[
- {1: } |
+ ^ |
{4:~ }|*3
{5:xtest-foo }|
:edit xtest-foo |
@@ -68,7 +68,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
feed_data('\027[O')
screen:expect {
grid = [[
- {1: } |
+ ^ |
{4:~ }|*3
{5:xtest-foo }|
:edit xtest-foo |
@@ -83,7 +83,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
screen:expect {
grid = [[
- {1:l}ine 1 |
+ ^line 1 |
line 2 |
line 3 |
line 4 |
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
index baf2bb6071..950ef2f58a 100644
--- a/test/functional/autocmd/termxx_spec.lua
+++ b/test/functional/autocmd/termxx_spec.lua
@@ -213,9 +213,11 @@ describe('autocmd TextChangedT', function()
end)
it('cannot delete terminal buffer', function()
- command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
+ command('autocmd TextChangedT * bwipe!')
tt.feed_data('a')
screen:expect({ any = 'E937: ' })
+ feed('<CR>')
+ command('autocmd! TextChangedT')
matches(
'^E937: Attempt to delete a buffer that is in use: term://',
api.nvim_get_vvar('errmsg')