To: vim_dev@googlegroups.com Subject: Patch 8.2.2489 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2489 Problem: current buffer is wrong after deletebufline() fails to delete a line in another buffer. Solution: Restore the current buffer. Files: src/evalbuffer.c, src/testdir/test_bufline.vim *** ../vim-8.2.2488/src/evalbuffer.c 2021-01-31 13:08:16.164367438 +0100 --- src/evalbuffer.c 2021-02-09 20:02:00.806223980 +0100 *************** *** 500,523 **** if (u_save(first - 1, last + 1) == FAIL) { rettv->vval.v_number = 1; // FAIL - return; } ! for (lnum = first; lnum <= last; ++lnum) ! ml_delete_flags(first, ML_DEL_MESSAGE); ! ! FOR_ALL_TAB_WINDOWS(tp, wp) ! if (wp->w_buffer == buf) ! { ! if (wp->w_cursor.lnum > last) ! wp->w_cursor.lnum -= count; ! else if (wp->w_cursor.lnum> first) ! wp->w_cursor.lnum = first; ! if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) ! wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count; ! } ! check_cursor_col(); ! deleted_lines_mark(first, count); if (!is_curbuf) { --- 500,524 ---- if (u_save(first - 1, last + 1) == FAIL) { rettv->vval.v_number = 1; // FAIL } + else + { + for (lnum = first; lnum <= last; ++lnum) + ml_delete_flags(first, ML_DEL_MESSAGE); ! FOR_ALL_TAB_WINDOWS(tp, wp) ! if (wp->w_buffer == buf) ! { ! if (wp->w_cursor.lnum > last) ! wp->w_cursor.lnum -= count; ! else if (wp->w_cursor.lnum> first) ! wp->w_cursor.lnum = first; ! if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) ! wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count; ! } ! check_cursor_col(); ! deleted_lines_mark(first, count); ! } if (!is_curbuf) { *** ../vim-8.2.2488/src/testdir/test_bufline.vim 2021-02-07 14:31:02.963000750 +0100 --- src/testdir/test_bufline.vim 2021-02-09 20:01:23.018307590 +0100 *************** *** 186,191 **** --- 186,202 ---- call assert_equal(0, deletebufline(b, 1)) call assert_equal(['b', 'c'], getbufline(b, 1, 2)) exe "bwipe! " . b + + edit XbufOne + let one = bufnr() + call setline(1, ['a', 'b', 'c']) + setlocal nomodifiable + split XbufTwo + let two = bufnr() + call assert_fails('call deletebufline(one, 1)', 'E21:') + call assert_equal(two, bufnr()) + bwipe! XbufTwo + bwipe! XbufOne endfunc func Test_appendbufline_redraw() *** ../vim-8.2.2488/src/version.c 2021-02-08 21:53:05.592963320 +0100 --- src/version.c 2021-02-09 19:47:33.824113130 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2489, /**/ -- CUSTOMER: You're not fooling anyone y'know. Look, isn't there something you can do? DEAD PERSON: I feel happy... I feel happy. [whop] CUSTOMER: Ah, thanks very much. MORTICIAN: Not at all. See you on Thursday. CUSTOMER: Right. The Quest for the Holy Grail (Monty Python) /// 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 ///