To: vim_dev@googlegroups.com Subject: Patch 8.2.4028 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4028 Problem: ml_get error with :doautoall and Visual area. (Sean Dewar) Solution: Disable Visual mode while executing autocommands. Files: src/structs.h, src/autocmd.c, src/testdir/test_autocmd.vim *** ../vim-8.2.4027/src/structs.h 2022-01-06 21:10:24.465027868 +0000 --- src/structs.h 2022-01-07 15:33:23.102464949 +0000 *************** *** 4031,4036 **** --- 4031,4037 ---- int save_prevwin_id; // ID of saved prevwin bufref_T new_curbuf; // new curbuf char_u *globaldir; // saved value of globaldir + int save_VIsual_active; // saved VIsual_active } aco_save_T; /* *** ../vim-8.2.4027/src/autocmd.c 2022-01-01 14:19:44.028353885 +0000 --- src/autocmd.c 2022-01-07 15:43:59.979736717 +0000 *************** *** 1424,1431 **** if (call_do_modelines && did_aucmd) do_modelines(0); } - - check_cursor(); // just in case lines got deleted } /* --- 1424,1429 ---- *************** *** 1532,1537 **** --- 1530,1539 ---- curbuf = buf; aco->new_curwin_id = curwin->w_id; set_bufref(&aco->new_curbuf, curbuf); + + // disable the Visual area, the position may be invalid in another buffer + aco->save_VIsual_active = VIsual_active; + VIsual_active = FALSE; } /* *************** *** 1656,1661 **** --- 1658,1668 ---- check_cursor(); } } + + check_cursor(); // just in case lines got deleted + VIsual_active = aco->save_VIsual_active; + if (VIsual_active) + check_pos(curbuf, &VIsual); } static int autocmd_nested = FALSE; *** ../vim-8.2.4027/src/testdir/test_autocmd.vim 2021-12-24 19:24:39.619189424 +0000 --- src/testdir/test_autocmd.vim 2022-01-07 15:41:42.932206968 +0000 *************** *** 2812,2817 **** --- 2812,2827 ---- %bwipe! endfunc + func Test_Visual_doautoall_redraw() + call setline(1, ['a', 'b']) + new + wincmd p + call feedkeys("G\", 'txn') + autocmd User Explode ++once redraw + doautoall User Explode + %bwipe! + endfunc + " This was using freed memory. func Test_BufNew_arglocal() arglocal *** ../vim-8.2.4027/src/version.c 2022-01-07 14:39:52.233887862 +0000 --- src/version.c 2022-01-07 15:31:20.663230302 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4028, /**/ -- hundred-and-one symptoms of being an internet addict: 245. You use Real Audio to listen to a radio station from a distant city rather than turn on your stereo system. /// 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 ///