patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Problem: Get ml_get error when deleting a line in 'completefunc'. (Yegappan
Lakshmanan)
Solution: Lock the text while evaluating 'completefunc'.
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index 9096fcd..ce55f6b 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -915,6 +915,23 @@
bw!
endfunc
+func Test_edit_completefunc_delete()
+ func CompleteFunc(findstart, base)
+ if a:findstart == 1
+ return col('.') - 1
+ endif
+ normal dd
+ return ['a', 'b']
+ endfunc
+ new
+ set completefunc=CompleteFunc
+ call setline(1, ['', 'abcd', ''])
+ 2d
+ call assert_fails("normal 2G$a\<C-X>\<C-U>", 'E565:')
+ bwipe!
+endfunc
+
+
func Test_edit_CTRL_Z()
" Ctrl-Z when insertmode is not set inserts it literally
new
@@ -1240,7 +1257,7 @@
try
call feedkeys("ix\<esc>", 'tnix')
call assert_fails(1, 'textlock')
- catch /^Vim\%((\a\+)\)\=:E523/ " catch E523: not allowed here
+ catch /^Vim\%((\a\+)\)\=:E565/ " catch E565: not allowed here
endtry
" TODO: Might be a bug: should x really be inserted here
call assert_equal(['xa'], getline(1, '$'))
@@ -1264,7 +1281,7 @@
try
call feedkeys("i\<c-x>\<c-u>\<esc>", 'tnix')
call assert_fails(1, 'change in complete function')
- catch /^Vim\%((\a\+)\)\=:E523/ " catch E523
+ catch /^Vim\%((\a\+)\)\=:E565/ " catch E565
endtry
delfu Complete
set completefunc=
diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim
index 9f66e3f..d23e0ad 100644
--- a/src/testdir/test_ex_mode.vim
+++ b/src/testdir/test_ex_mode.vim
@@ -158,13 +158,13 @@
func Test_ex_mode_errors()
" Not allowed to enter ex mode when text is locked
au InsertCharPre <buffer> normal! gQ<CR>
- let caught_e523 = 0
+ let caught_e565 = 0
try
call feedkeys("ix\<esc>", 'xt')
- catch /^Vim\%((\a\+)\)\=:E523/ " catch E523
- let caught_e523 = 1
+ catch /^Vim\%((\a\+)\)\=:E565/ " catch E565
+ let caught_e565 = 1
endtry
- call assert_equal(1, caught_e523)
+ call assert_equal(1, caught_e565)
au! InsertCharPre
endfunc
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index 9369c1b..868ac6f 100644
--- a/src/testdir/test_excmd.vim
+++ b/src/testdir/test_excmd.vim
@@ -354,15 +354,15 @@
func Test_run_excmd_with_text_locked()
" :quit
let cmd = ":\<C-\>eexecute('quit')\<CR>\<C-C>"
- call assert_fails("call feedkeys(cmd, 'xt')", 'E523:')
+ call assert_fails("call feedkeys(cmd, 'xt')", 'E565:')
" :qall
let cmd = ":\<C-\>eexecute('qall')\<CR>\<C-C>"
- call assert_fails("call feedkeys(cmd, 'xt')", 'E523:')
+ call assert_fails("call feedkeys(cmd, 'xt')", 'E565:')
" :exit
let cmd = ":\<C-\>eexecute('exit')\<CR>\<C-C>"
- call assert_fails("call feedkeys(cmd, 'xt')", 'E523:')
+ call assert_fails("call feedkeys(cmd, 'xt')", 'E565:')
" :close - should be ignored
new
@@ -370,7 +370,7 @@
call assert_equal(2, winnr('$'))
close
- call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E523:')
+ call assert_fails("call feedkeys(\":\<C-R>=execute('bnext')\<CR>\", 'xt')", 'E565:')
endfunc
" Test for the :verbose command
diff --git a/src/testdir/test_gf.vim b/src/testdir/test_gf.vim
index 829b7c2..736a315 100644
--- a/src/testdir/test_gf.vim
+++ b/src/testdir/test_gf.vim
@@ -134,13 +134,13 @@
" gf is not allowed when text is locked
au InsertCharPre <buffer> normal! gF<CR>
- let caught_e523 = 0
+ let caught_e565 = 0
try
call feedkeys("ix\<esc>", 'xt')
- catch /^Vim\%((\a\+)\)\=:E523/ " catch E523
- let caught_e523 = 1
+ catch /^Vim\%((\a\+)\)\=:E565/ " catch E565
+ let caught_e565 = 1
endtry
- call assert_equal(1, caught_e523)
+ call assert_equal(1, caught_e565)
au! InsertCharPre
bwipe!
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index e96d5fd..9890377 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -334,19 +334,17 @@
endif
endfunc
-" Test that nothing happens if the 'completefunc' opens
-" a new window (no completion, no crash)
+" Test that nothing happens if the 'completefunc' tries to open
+" a new window (fails to open window, continues)
func Test_completefunc_opens_new_window_one()
new
let winid = win_getid()
setlocal completefunc=DummyCompleteOne
call setline(1, 'one')
/^one
- call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E839:')
- call assert_notequal(winid, win_getid())
- q!
+ call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E565:')
call assert_equal(winid, win_getid())
- call assert_equal('', getline(1))
+ call assert_equal('oneDEF', getline(1))
q!
endfunc