File tree Expand file tree Collapse file tree 5 files changed +36
-1
lines changed
Expand file tree Collapse file tree 5 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -2147,6 +2147,7 @@ test_arglist \
21472147 test_langmap \
21482148 test_largefile \
21492149 test_lispwords \
2150+ test_lua \
21502151 test_man \
21512152 test_mapping \
21522153 test_marks \
Original file line number Diff line number Diff line change @@ -1716,6 +1716,8 @@ ex_luado(exarg_T *eap)
17161716 const char * s = (const char * ) eap -> arg ;
17171717 luaL_Buffer b ;
17181718 size_t len ;
1719+ buf_T * was_curbuf = curbuf ;
1720+
17191721 if (lua_init () == FAIL ) return ;
17201722 if (u_save (eap -> line1 - 1 , eap -> line2 + 1 ) == FAIL )
17211723 {
@@ -1739,6 +1741,10 @@ ex_luado(exarg_T *eap)
17391741 lua_replace (L , -2 ); /* function -> body */
17401742 for (l = eap -> line1 ; l <= eap -> line2 ; l ++ )
17411743 {
1744+ /* Check the line number, the command my have deleted lines. */
1745+ if (l > curbuf -> b_ml .ml_line_count )
1746+ break ;
1747+
17421748 lua_pushvalue (L , -1 ); /* function */
17431749 luaV_pushline (L , curbuf , l ); /* current line as arg */
17441750 lua_pushinteger (L , l ); /* current line number as arg */
@@ -1747,6 +1753,9 @@ ex_luado(exarg_T *eap)
17471753 luaV_emsg (L );
17481754 break ;
17491755 }
1756+ /* Catch the command switching to another buffer. */
1757+ if (curbuf != was_curbuf )
1758+ break ;
17501759 if (lua_isstring (L , -1 )) /* update line? */
17511760 {
17521761#ifdef HAVE_SANDBOX
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ NEW_TESTS = test_arglist.res \
164164 test_job_fails.res \
165165 test_json.res \
166166 test_langmap.res \
167+ test_lua.res \
167168 test_man.res \
168169 test_marks.res \
169170 test_matchadd_conceal.res \
@@ -172,8 +173,8 @@ NEW_TESTS = test_arglist.res \
172173 test_nested_function.res \
173174 test_netbeans.res \
174175 test_normal.res \
175- test_paste.res \
176176 test_packadd.res \
177+ test_paste.res \
177178 test_perl.res \
178179 test_profile.res \
179180 test_python2.res \
Original file line number Diff line number Diff line change 1+ " Tests for Lua.
2+ " TODO: move tests from test85.in here.
3+
4+ if ! has (' lua' )
5+ finish
6+ endif
7+
8+ func Test_luado ()
9+ new
10+ call setline (1 , [' one' , ' two' , ' three' ])
11+ luado vim .command (" %d_" )
12+ bwipe!
13+
14+ " Check switching to another buffer does not trigger ml_get error.
15+ new
16+ let wincount = winnr (' $' )
17+ call setline (1 , [' one' , ' two' , ' three' ])
18+ luado vim .command (" new" )
19+ call assert_equal (wincount + 1 , winnr (' $' ))
20+ bwipe!
21+ bwipe!
22+ endfunc
Original file line number Diff line number Diff line change @@ -764,6 +764,8 @@ static char *(features[]) =
764764
765765static int included_patches [] =
766766{ /* Add new patch number below this line */
767+ /**/
768+ 268 ,
767769/**/
768770 267 ,
769771/**/
You can’t perform that action at this time.
0 commit comments