{
int state;
linenr_T i;
+ buf_T *was_curbuf = curbuf;
if (ensure_ruby_initialized())
{
{
VALUE line;
+ if (i > curbuf->b_ml.ml_line_count)
+ break;
line = vim_str2rb_enc_str((char *)ml_get(i));
rb_lastline_set(line);
eval_enc_string_protect((char *) eap->arg, &state);
error_print(state);
break;
}
+ if (was_curbuf != curbuf)
+ break;
line = rb_lastline_get();
if (!NIL_P(line))
{
redir END
call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
endfunc
+
+func Test_rubydo()
+ " Check deleting lines does not trigger ml_get error.
+ new
+ call setline(1, ['one', 'two', 'three'])
+ rubydo 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'])
+ rubydo Vim.command("new")
+ call assert_equal(wincount + 1, winnr('$'))
+ bwipe!
+ bwipe!
+endfunc