To: vim_dev@googlegroups.com Subject: Patch 8.2.3097 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3097 Problem: Crash when using "quit" at recovery prompt and autocommands are triggered. Solution: Block autocommands when creating an empty buffer to use as the current buffer. (closes #8506) Files: src/buffer.c, src/testdir/test_swap.vim *** ../vim-8.2.3096/src/buffer.c 2021-06-27 22:03:28.637707737 +0200 --- src/buffer.c 2021-07-04 13:12:00.844832388 +0200 *************** *** 1130,1136 **** --- 1130,1141 ---- close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE, FALSE); if (old_curbuf == NULL || !bufref_valid(old_curbuf) || old_curbuf->br_buf == curbuf) + { + // Block autocommands here because curwin->w_buffer is NULL. + block_autocmds(); buf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED); + unblock_autocmds(); + } else buf = old_curbuf->br_buf; if (buf != NULL) *** ../vim-8.2.3096/src/testdir/test_swap.vim 2021-06-23 21:44:03.249880242 +0200 --- src/testdir/test_swap.vim 2021-07-04 13:13:53.657012734 +0200 *************** *** 360,365 **** --- 360,366 ---- let buf = RunVimInTerminal('', {'rows': 20}) call term_sendkeys(buf, ":set nomore\n") call term_sendkeys(buf, ":set noruler\n") + call term_sendkeys(buf, ":split Xfile1\n") call TermWait(buf) call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: $', term_getline(buf, 20))}) *************** *** 371,378 **** --- 372,390 ---- call TermWait(buf) call WaitForAssert({-> assert_match('^1$', term_getline(buf, 20))}) call StopVimInTerminal(buf) + + " This caused Vim to crash when typing "q". + " TODO: it does not actually reproduce the crash. + call writefile(['au BufAdd * set virtualedit=all'], 'Xvimrc') + + let buf = RunVimInTerminal('-u Xvimrc Xfile1', {'rows': 20, 'wait_for_ruler': 0}) + call TermWait(buf) + call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:', term_getline(buf, 20))}) + call term_sendkeys(buf, "q") + %bwipe! call delete('Xfile1') + call delete('Xvimrc') endfunc func Test_swap_symlink() *** ../vim-8.2.3096/src/version.c 2021-07-04 12:30:00.215304320 +0200 --- src/version.c 2021-07-04 13:16:22.753186086 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3097, /**/ -- From "know your smileys": ¯\_(ツ)_/¯ Shrug /// 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 ///