mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
vim-patch:9.0.1036: undo misbehaves when writing from an insert mode mapping
Problem: Undo misbehaves when writing from an insert mode mapping. Solution: Sync undo when writing. (closes vim/vim#11674)3f8f827723
Co-authored-by: Bram Moolenaar <Bram@vim.org> (cherry picked from commit70d6c335b1
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
927074c97a
commit
eacc8230ed
@@ -9,6 +9,7 @@ local feed = helpers.feed
|
||||
local feed_command = helpers.feed_command
|
||||
local insert = helpers.insert
|
||||
local funcs = helpers.funcs
|
||||
local exec = helpers.exec
|
||||
|
||||
local function lastmessage()
|
||||
local messages = funcs.split(funcs.execute('messages'), '\n')
|
||||
@@ -67,6 +68,40 @@ 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)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe(':undo! command', function()
|
||||
|
Reference in New Issue
Block a user