patch 8.0.0265: may get ml_get error when :pydo deletes lines
Problem: May get ml_get error when :pydo deletes lines or switches to
another buffer. (Nikolai Pavlov, issue #1421)
Solution: Check the buffer and line every time.
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 12abb78..c01634c 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -176,6 +176,8 @@
test_packadd.res \
test_perl.res \
test_profile.res \
+ test_python2.res \
+ test_python3.res \
test_pyx2.res \
test_pyx3.res \
test_quickfix.res \
diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim
new file mode 100644
index 0000000..fb98c1e
--- /dev/null
+++ b/src/testdir/test_python2.vim
@@ -0,0 +1,24 @@
+" Test for python 2 commands.
+" TODO: move tests from test87.in here.
+
+if !has('python')
+ finish
+endif
+
+func Test_pydo()
+ " Check deleting lines does not trigger ml_get error.
+ py import vim
+ new
+ call setline(1, ['one', 'two', 'three'])
+ pydo vim.command("%d_")
+ bwipe!
+
+ " Check switching to another buffer does not trigger ml_get error.
+ new
+ let wincount = winnr('$')
+ call setline(1, ['one', 'two', 'three'])
+ pydo vim.command("new")
+ call assert_equal(wincount + 1, winnr('$'))
+ bwipe!
+ bwipe!
+endfunc
diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim
new file mode 100644
index 0000000..bb241da
--- /dev/null
+++ b/src/testdir/test_python3.vim
@@ -0,0 +1,24 @@
+" Test for python 2 commands.
+" TODO: move tests from test88.in here.
+
+if !has('python3')
+ finish
+endif
+
+func Test_py3do()
+ " Check deleting lines does not trigger an ml_get error.
+ py3 import vim
+ new
+ call setline(1, ['one', 'two', 'three'])
+ py3do vim.command("%d_")
+ bwipe!
+
+ " Check switching to another buffer does not trigger an ml_get error.
+ new
+ let wincount = winnr('$')
+ call setline(1, ['one', 'two', 'three'])
+ py3do vim.command("new")
+ call assert_equal(wincount + 1, winnr('$'))
+ bwipe!
+ bwipe!
+endfunc