To: vim_dev@googlegroups.com Subject: Patch 8.2.4166 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4166 Problem: Undo synced when switching buffer in another window. Solution: Do not sync undo when not needed. (closes #9575) Files: src/buffer.c, src/testdir/test_timers.vim *** ../vim-8.2.4165/src/buffer.c 2022-01-19 13:32:53.439930008 +0000 --- src/buffer.c 2022-01-20 21:00:03.586057364 +0000 *************** *** 1744,1750 **** { win_T *previouswin = curwin; ! if (prevbuf == curbuf) u_sync(FALSE); close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf, unload ? action : (action == DOBUF_GOTO --- 1744,1754 ---- { win_T *previouswin = curwin; ! // Do not sync when in Insert mode and the buffer is open in ! // another window, might be a timer doing something in another ! // window. ! if (prevbuf == curbuf ! && ((State & INSERT) == 0 || curbuf->b_nwindows <= 1)) u_sync(FALSE); close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf, unload ? action : (action == DOBUF_GOTO *** ../vim-8.2.4165/src/testdir/test_timers.vim 2021-12-10 10:57:04.808422644 +0000 --- src/testdir/test_timers.vim 2022-01-20 20:59:26.466773079 +0000 *************** *** 484,488 **** --- 484,511 ---- call delete('XTest_timermessage') endfunc + func Test_timer_using_win_execute_undo_sync() + let bufnr1 = bufnr() + new + let g:bufnr2 = bufnr() + let g:winid = win_getid() + exe "buffer " .. bufnr1 + wincmd w + call setline(1, ['test']) + autocmd InsertEnter * call timer_start(100, { -> win_execute(g:winid, 'buffer ' .. g:bufnr2) }) + call timer_start(200, { -> feedkeys("\bbbb\") }) + call feedkeys("Oaaaa", 'x!t') + " will hang here until the second timer fires + call assert_equal(['aaaa', 'bbbb', 'test'], getline(1, '$')) + undo + call assert_equal(['test'], getline(1, '$')) + + bwipe! + bwipe! + unlet g:winid + unlet g:bufnr2 + au! InsertEnter + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4165/src/version.c 2022-01-20 20:18:23.661848798 +0000 --- src/version.c 2022-01-20 20:43:22.405491999 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4166, /**/ -- TIM: To the north there lies a cave, the cave of Caerbannog, wherein, carved in mystic runes, upon the very living rock, the last words of Olfin Bedwere of Rheged make plain the last resting place of the most Holy Grail. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///