aboutsummaryrefslogtreecommitdiff
path: root/test/functional/editor/undo_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
commit9243becbedbb6a1592208051f8fa2b090dcc5e7d (patch)
tree607c2a862ec3f4399b8766383f6f8e04c4aa43b4 /test/functional/editor/undo_spec.lua
parent9e40b6e9e1bc67f2d856adb837ee64dd0e25b717 (diff)
parent3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 (diff)
downloadrneovim-usermarks.tar.gz
rneovim-usermarks.tar.bz2
rneovim-usermarks.zip
Merge remote-tracking branch 'upstream/master' into usermarksusermarks
Diffstat (limited to 'test/functional/editor/undo_spec.lua')
-rw-r--r--test/functional/editor/undo_spec.lua75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/functional/editor/undo_spec.lua b/test/functional/editor/undo_spec.lua
index a041428cdc..d66ab352ef 100644
--- a/test/functional/editor/undo_spec.lua
+++ b/test/functional/editor/undo_spec.lua
@@ -9,6 +9,8 @@ local feed = helpers.feed
local feed_command = helpers.feed_command
local insert = helpers.insert
local funcs = helpers.funcs
+local exec = helpers.exec
+local exec_lua = helpers.exec_lua
local function lastmessage()
local messages = funcs.split(funcs.execute('messages'), '\n')
@@ -67,6 +69,79 @@ describe('u CTRL-R g- g+', function()
undo_and_redo(4, 'u', '<C-r>', '1')
undo_and_redo(4, 'g-', 'g+', '1')
end)
+
+ describe('undo works correctly when writing in Insert mode', function()
+ before_each(function()
+ exec([[
+ edit Xtestfile.txt
+ set undolevels=100 undofile
+ write
+ ]])
+ end)
+
+ after_each(function()
+ command('bwipe!')
+ os.remove('Xtestfile.txt')
+ os.remove('Xtestfile.txt.un~')
+ end)
+
+ -- oldtest: Test_undo_after_write()
+ it('using <Cmd> mapping', function()
+ command('imap . <Cmd>write<CR>')
+ feed('Otest.<CR>boo!!!<Esc>')
+ expect([[
+ test
+ boo!!!
+ ]])
+
+ feed('u')
+ expect([[
+ test
+ ]])
+
+ feed('u')
+ expect('')
+ end)
+
+ it('using Lua mapping', function()
+ exec_lua([[
+ vim.api.nvim_set_keymap('i', '.', '', {callback = function()
+ vim.cmd('write')
+ end})
+ ]])
+ feed('Otest.<CR>boo!!!<Esc>')
+ expect([[
+ test
+ boo!!!
+ ]])
+
+ feed('u')
+ expect([[
+ test
+ ]])
+
+ feed('u')
+ expect('')
+ end)
+
+ it('using RPC call', function()
+ feed('Otest')
+ command('write')
+ feed('<CR>boo!!!<Esc>')
+ expect([[
+ test
+ boo!!!
+ ]])
+
+ feed('u')
+ expect([[
+ test
+ ]])
+
+ feed('u')
+ expect('')
+ end)
+ end)
end)
describe(':undo! command', function()