Mercurial > vim
comparison src/if_ruby.c @ 10761:721af7a9b4b4 v8.0.0270
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
commit https://github.com/vim/vim/commit/c593fee0e5e850f7e75be41f5d1751f28892a27f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 29 23:11:25 2017 +0100
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Problem: May get ml_get error when :rubydo deletes lines or switches to
another buffer. (Nikolai Pavlov, issue https://github.com/vim/vim/issues/1421)
Solution: Check the buffer and line every time.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 Jan 2017 23:15:50 +0100 |
parents | df1abc85b169 |
children | df498e3e34fc |
comparison
equal
deleted
inserted
replaced
10760:21d42e500b82 | 10761:721af7a9b4b4 |
---|---|
781 | 781 |
782 void ex_rubydo(exarg_T *eap) | 782 void ex_rubydo(exarg_T *eap) |
783 { | 783 { |
784 int state; | 784 int state; |
785 linenr_T i; | 785 linenr_T i; |
786 buf_T *was_curbuf = curbuf; | |
786 | 787 |
787 if (ensure_ruby_initialized()) | 788 if (ensure_ruby_initialized()) |
788 { | 789 { |
789 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) | 790 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) |
790 return; | 791 return; |
791 for (i = eap->line1; i <= eap->line2; i++) | 792 for (i = eap->line1; i <= eap->line2; i++) |
792 { | 793 { |
793 VALUE line; | 794 VALUE line; |
794 | 795 |
796 if (i > curbuf->b_ml.ml_line_count) | |
797 break; | |
795 line = vim_str2rb_enc_str((char *)ml_get(i)); | 798 line = vim_str2rb_enc_str((char *)ml_get(i)); |
796 rb_lastline_set(line); | 799 rb_lastline_set(line); |
797 eval_enc_string_protect((char *) eap->arg, &state); | 800 eval_enc_string_protect((char *) eap->arg, &state); |
798 if (state) | 801 if (state) |
799 { | 802 { |
800 error_print(state); | 803 error_print(state); |
801 break; | 804 break; |
802 } | 805 } |
806 if (was_curbuf != curbuf) | |
807 break; | |
803 line = rb_lastline_get(); | 808 line = rb_lastline_get(); |
804 if (!NIL_P(line)) | 809 if (!NIL_P(line)) |
805 { | 810 { |
806 if (TYPE(line) != T_STRING) | 811 if (TYPE(line) != T_STRING) |
807 { | 812 { |