aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/safestate_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 22:39:54 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 22:39:54 +0000
commit21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch)
tree84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /test/functional/autocmd/safestate_spec.lua
parentd9c904f85a23a496df4eb6be42aa43f007b22d50 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-colorcolchar.tar.gz
rneovim-colorcolchar.tar.bz2
rneovim-colorcolchar.zip
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'test/functional/autocmd/safestate_spec.lua')
-rw-r--r--test/functional/autocmd/safestate_spec.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/functional/autocmd/safestate_spec.lua b/test/functional/autocmd/safestate_spec.lua
new file mode 100644
index 0000000000..73693749e4
--- /dev/null
+++ b/test/functional/autocmd/safestate_spec.lua
@@ -0,0 +1,57 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local eq = helpers.eq
+local exec = helpers.exec
+local feed = helpers.feed
+local meths = helpers.meths
+
+before_each(clear)
+
+describe('SafeState autocommand', function()
+ local function create_autocmd()
+ exec([[
+ let g:safe = 0
+ autocmd SafeState * ++once let g:safe += 1
+ ]])
+ end
+
+ it('with pending operator', function()
+ feed('d')
+ create_autocmd()
+ eq(0, meths.get_var('safe'))
+ feed('d')
+ eq(1, meths.get_var('safe'))
+ end)
+
+ it('with specified register', function()
+ feed('"r')
+ create_autocmd()
+ eq(0, meths.get_var('safe'))
+ feed('x')
+ eq(1, meths.get_var('safe'))
+ end)
+
+ it('with i_CTRL-O', function()
+ feed('i<C-O>')
+ create_autocmd()
+ eq(0, meths.get_var('safe'))
+ feed('x')
+ eq(1, meths.get_var('safe'))
+ end)
+
+ it('with Insert mode completion', function()
+ feed('i<C-X><C-V>')
+ create_autocmd()
+ eq(0, meths.get_var('safe'))
+ feed('<C-X><C-Z>')
+ eq(1, meths.get_var('safe'))
+ end)
+
+ it('with Cmdline completion', function()
+ feed(':<Tab>')
+ create_autocmd()
+ eq(0, meths.get_var('safe'))
+ feed('<C-E>')
+ eq(1, meths.get_var('safe'))
+ end)
+end)