0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.0.0268: may get ml_get error when :luado deletes lines

Problem:    May get ml_get error when :luado deletes lines or switches to
            another buffer. (Nikolai Pavlov, issue #1421)
Solution:   Check the buffer and line every time.
This commit is contained in:
Bram Moolenaar
2017-01-29 22:48:45 +01:00
parent 6fe2eb43d2
commit d58f03b1c2
5 changed files with 36 additions and 1 deletions

View File

@@ -1716,6 +1716,8 @@ ex_luado(exarg_T *eap)
const char *s = (const char *) eap->arg;
luaL_Buffer b;
size_t len;
buf_T *was_curbuf = curbuf;
if (lua_init() == FAIL) return;
if (u_save(eap->line1 - 1, eap->line2 + 1) == FAIL)
{
@@ -1739,6 +1741,10 @@ ex_luado(exarg_T *eap)
lua_replace(L, -2); /* function -> body */
for (l = eap->line1; l <= eap->line2; l++)
{
/* Check the line number, the command my have deleted lines. */
if (l > curbuf->b_ml.ml_line_count)
break;
lua_pushvalue(L, -1); /* function */
luaV_pushline(L, curbuf, l); /* current line as arg */
lua_pushinteger(L, l); /* current line number as arg */
@@ -1747,6 +1753,9 @@ ex_luado(exarg_T *eap)
luaV_emsg(L);
break;
}
/* Catch the command switching to another buffer. */
if (curbuf != was_curbuf)
break;
if (lua_isstring(L, -1)) /* update line? */
{
#ifdef HAVE_SANDBOX