To: vim_dev@googlegroups.com Subject: Patch 8.0.0270 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0270 Problem: May get ml_get error when :rubydo deletes lines or switches to another buffer. (Nikolai Pavlov, issue #1421) Solution: Check the buffer and line every time. Files: src/if_ruby.c, src/testdir/test_ruby.vim *** ../vim-8.0.0269/src/if_ruby.c 2017-01-15 16:58:59.448070798 +0100 --- src/if_ruby.c 2017-01-29 23:09:35.653212880 +0100 *************** *** 783,788 **** --- 783,789 ---- { int state; linenr_T i; + buf_T *was_curbuf = curbuf; if (ensure_ruby_initialized()) { *************** *** 792,797 **** --- 793,800 ---- { 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); *************** *** 800,805 **** --- 803,810 ---- error_print(state); break; } + if (was_curbuf != curbuf) + break; line = rb_lastline_get(); if (!NIL_P(line)) { *** ../vim-8.0.0269/src/testdir/test_ruby.vim 2016-06-21 22:46:47.000000000 +0200 --- src/testdir/test_ruby.vim 2017-01-29 23:08:10.821775612 +0100 *************** *** 32,34 **** --- 32,51 ---- 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 *** ../vim-8.0.0269/src/version.c 2017-01-29 22:59:08.253373379 +0100 --- src/version.c 2017-01-29 23:10:21.992905463 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 270, /**/ -- Two cows are standing together in a field. One asks the other: "So what do you think about this Mad Cow Disease?" The other replies: "That doesn't concern me. I'm a helicopter." /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///