summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_autocmd.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-07 19:05:01 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-07 19:05:01 +0200
commit91d2e783b41ca900bc603b3cb5e083c8a4a33170 (patch)
treef42a1d2db656122fb069474859514d9cb62523c4 /src/testdir/test_autocmd.vim
parent917e32bda5a93941fbbccab09ae3960114b67188 (diff)
patch 8.1.0245: calling setline() in TextChangedI autocmd breaks undov8.1.0245
Problem: Calling setline() in TextChangedI autocmd breaks undo. (Jason Felice) Solution: Don't save lines for undo when already saved. (closes #3291)
Diffstat (limited to 'src/testdir/test_autocmd.vim')
-rw-r--r--src/testdir/test_autocmd.vim27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 19c54d1567..b52493fcb4 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -587,7 +587,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
@@ -1313,6 +1313,31 @@ 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()
+ new
+ call test_override('char_avail', 1)
+ autocmd TextChangedI <buffer> call SetLineOne()
+ call feedkeys("i(\<CR>\<Esc>", '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
+
func Test_Changed_FirstTime()
if !has('terminal') || has('gui_running')
return