To: vim_dev@googlegroups.com Subject: Patch 9.0.0198 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0198 Problem: ml_get error when switching buffer in Visual mode. Solution: End Visual mode when switching buffer. (closes #10902) Files: src/buffer.c, src/testdir/test_visual.vim *** ../vim-9.0.0197/src/buffer.c 2022-07-27 15:48:42.339954972 +0100 --- src/buffer.c 2022-08-13 13:44:25.745267341 +0100 *************** *** 1818,1823 **** --- 1818,1831 ---- static void enter_buffer(buf_T *buf) { + // when closing the current buffer stop Visual mode + if (VIsual_active + #if defined(EXITFREE) + && !entered_free_all_mem + #endif + ) + end_visual_mode(); + // Get the buffer in the current window. curwin->w_buffer = buf; curbuf = buf; *** ../vim-9.0.0197/src/testdir/test_visual.vim 2022-07-01 15:26:09.298541278 +0100 --- src/testdir/test_visual.vim 2022-08-13 13:49:02.134102682 +0100 *************** *** 1481,1485 **** --- 1481,1505 ---- bwipe! endfunc + func Test_switch_buffer_ends_visual_mode() + enew + call setline(1, 'foo') + set hidden + set virtualedit=all + let buf1 = bufnr() + enew + let buf2 = bufnr() + call setline(1, ['', '', '', '']) + call cursor(4, 5) + call feedkeys("\3k4h", 'xt') + exe 'buffer' buf1 + call assert_equal('n', mode()) + + set nohidden + set virtualedit= + bwipe! + exe 'bwipe!' buf2 + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0197/src/version.c 2022-08-13 13:21:27.019080973 +0100 --- src/version.c 2022-08-13 13:45:24.248482267 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 198, /**/ -- You were lucky to have a LAKE! There were a hundred and sixty of us living in a small shoebox in the middle of the road. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///