From d45efa5793e8b60192cc5b1f80d112d0401b14d3 Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Wed, 8 Aug 2018 16:02:32 -0700 Subject: vim-patch:8.1.0245: calling setline() in TextChangedI autocmd breaks undo Problem: Calling setline() in TextChangedI autocmd breaks undo. (Jason Felice) Solution: Don't save lines for undo when already saved. (closes vim/vim#3291) https://github.com/vim/vim/commit/91d2e783b41ca900bc603b3cb5e083c8a4a33170 --- src/nvim/testdir/test_autocmd.vim | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 772b3f721c..547ffe5a46 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -567,7 +567,7 @@ func Test_OptionSet() " Cleanup au! OptionSet for opt in ['nu', 'ai', 'acd', 'ar', 'bs', 'backup', 'cul', 'cp'] - exe printf(":set %s&vi", opt) + exe printf(":set %s&vim", opt) endfor call test_override('starting', 0) delfunc! AutoCommandOptionSet @@ -1221,3 +1221,29 @@ func Test_ChangedP() bw! endfunc + +let g:setline_handled = v:false +func! SetLineOne() + if !g:setline_handled + call setline(1, "(x)") + let g:setline_handled = v:true + endif +endfunc + +func Test_TextChangedI_with_setline() + throw 'skipped: Nvim does not support test_override()' + new + call test_override('char_avail', 1) + autocmd TextChangedI call SetLineOne() + call feedkeys("i(\\", 'tx') + call assert_equal('(', getline(1)) + call assert_equal('x)', getline(2)) + undo + call assert_equal('(', getline(1)) + call assert_equal('', getline(2)) + undo + call assert_equal('', getline(1)) + + call test_override('starting', 0) + bwipe! +endfunc -- cgit From 3c41df269173b68aa5572df8c5b7cae408229b88 Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Wed, 8 Aug 2018 16:11:32 -0700 Subject: vim-patch:8.1.0256: using setline() in TextChangedI splits undo Problem: Using setline() in TextChangedI splits undo. Solution: Use another solution for undo not working properly. https://github.com/vim/vim/commit/9fa9506853516c82851baec643aa47458cb8b3bc This deviates from Vim in the handling of the CursorHoldI event. In Vim, any buffer changes are merged into the insert. In Neovim, CursorHoldI is handled via the multiqueue, and the point at which the cursor hold is implemented (in input.c) doesn't know enough about it. Making all queued events merge into the insert seems more wronger since changes by other asynchronous events really should be separately undoable. --- src/nvim/testdir/test_autocmd.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 547ffe5a46..e4ab3ccea8 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1239,10 +1239,8 @@ func Test_TextChangedI_with_setline() call assert_equal('(', getline(1)) call assert_equal('x)', getline(2)) undo - call assert_equal('(', getline(1)) - call assert_equal('', getline(2)) - undo call assert_equal('', getline(1)) + call assert_equal('', getline(2)) call test_override('starting', 0) bwipe! -- cgit