aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-16 07:34:02 +0800
committerGitHub <noreply@github.com>2024-02-16 07:34:02 +0800
commit04dfa2eea914086a9f42a5a00a33e9524f9fded4 (patch)
treec6502c68406be5ae3ef88e292f81cff9f9d71ac2 /test
parentd60eeacae4ce4aa780636b90199ac20af609e91b (diff)
parent163add40b8b98b91dfb8eff589f49dc75f1032ea (diff)
downloadrneovim-04dfa2eea914086a9f42a5a00a33e9524f9fded4.tar.gz
rneovim-04dfa2eea914086a9f42a5a00a33e9524f9fded4.tar.bz2
rneovim-04dfa2eea914086a9f42a5a00a33e9524f9fded4.zip
Merge pull request #27485 from zeertzjq/vim-9.1.0112
vim-patch:9.1.{0112,0113}
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/autocmd_spec.lua40
-rw-r--r--test/old/testdir/test_autocmd.vim28
2 files changed, 68 insertions, 0 deletions
diff --git a/test/functional/legacy/autocmd_spec.lua b/test/functional/legacy/autocmd_spec.lua
new file mode 100644
index 0000000000..97051f3d3f
--- /dev/null
+++ b/test/functional/legacy/autocmd_spec.lua
@@ -0,0 +1,40 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local write_file = helpers.write_file
+local command = helpers.command
+local feed = helpers.feed
+local api = helpers.api
+local eq = helpers.eq
+
+before_each(clear)
+
+-- oldtest: Test_autocmd_invalidates_undo_on_textchanged()
+it('no E440 in quickfix window when autocommand invalidates undo', function()
+ write_file(
+ 'XTest_autocmd_invalidates_undo_on_textchanged',
+ [[
+ set hidden
+ " create quickfix list (at least 2 lines to move line)
+ vimgrep /u/j %
+
+ " enter quickfix window
+ cwindow
+
+ " set modifiable
+ setlocal modifiable
+
+ " set autocmd to clear quickfix list
+
+ autocmd! TextChanged <buffer> call setqflist([])
+ " move line
+ move+1
+ ]]
+ )
+ finally(function()
+ os.remove('XTest_autocmd_invalidates_undo_on_textchanged')
+ end)
+ command('edit XTest_autocmd_invalidates_undo_on_textchanged')
+ command('so %')
+ feed('G')
+ eq('', api.nvim_get_vvar('errmsg'))
+end)
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 0a28ae6147..6901627c17 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -3840,4 +3840,32 @@ func Test_autocmd_shortmess()
delfunc SetupVimTest_shm
endfunc
+func Test_autocmd_invalidates_undo_on_textchanged()
+ CheckRunVimInTerminal
+ let script =<< trim END
+ set hidden
+ " create quickfix list (at least 2 lines to move line)
+ vimgrep /u/j %
+
+ " enter quickfix window
+ cwindow
+
+ " set modifiable
+ setlocal modifiable
+
+ " set autocmd to clear quickfix list
+
+ autocmd! TextChanged <buffer> call setqflist([])
+ " move line
+ move+1
+ END
+ call writefile(script, 'XTest_autocmd_invalidates_undo_on_textchanged', 'D')
+ let buf = RunVimInTerminal('XTest_autocmd_invalidates_undo_on_textchanged', {'rows': 20})
+ call term_sendkeys(buf, ":so %\<cr>")
+ call term_sendkeys(buf, "G")
+ call WaitForAssert({-> assert_match('^XTest_autocmd_invalidates_undo_on_textchanged\s*$', term_getline(buf, 20))}, 1000)
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab