To: vim_dev@googlegroups.com Subject: Patch 8.2.2271 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2271 Problem: ml_get error when changing hidden buffer in Python. Solution: Block updating folds. (closes #7598) Files: src/evalbuffer.c, src/testdir/test_python3.vim *** ../vim-8.2.2270/src/evalbuffer.c 2020-10-22 18:23:34.429289412 +0200 --- src/evalbuffer.c 2021-01-02 13:48:38.246917302 +0100 *************** *** 807,812 **** --- 807,815 ---- switch_buffer(bufref_T *save_curbuf, buf_T *buf) { block_autocmds(); + #ifdef FEAT_FOLDING + ++disable_fold_update; + #endif set_bufref(save_curbuf, curbuf); --curbuf->b_nwindows; curbuf = buf; *************** *** 821,826 **** --- 824,832 ---- restore_buffer(bufref_T *save_curbuf) { unblock_autocmds(); + #ifdef FEAT_FOLDING + --disable_fold_update; + #endif // Check for valid buffer, just in case. if (bufref_valid(save_curbuf)) { *** ../vim-8.2.2270/src/testdir/test_python3.vim 2020-12-22 12:50:07.368223959 +0100 --- src/testdir/test_python3.vim 2021-01-02 13:46:35.735351774 +0100 *************** *** 4016,4019 **** --- 4016,4052 ---- sunmap @ endfunc + func Test_python3_fold_hidden_buffer() + CheckFeature folding + + set fdm=expr fde=Fde(v:lnum) + let b:regex = '^' + func Fde(lnum) + let ld = [{}] + let lines = bufnr('%')->getbufline(1, '$') + let was_import = 0 + for lnum in range(1, len(lines)) + let line = lines[lnum] + call add(ld, {'a': b:regex}) + let ld[lnum].foldexpr = was_import ? 1 : '>1' + let was_import = 1 + endfor + return ld[a:lnum].foldexpr + endfunc + + call setline(1, repeat([''], 15) + repeat(['from'], 3)) + eval repeat(['x'], 17)->writefile('Xa.txt') + split Xa.txt + py3 import vim + py3 b = vim.current.buffer + py3 aaa = b[:] + hide + py3 b[:] = aaa + + call delete('Xa.txt') + set fdm& fde& + delfunc Fde + bwipe! Xa.txt + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.2270/src/version.c 2021-01-02 12:45:38.234364061 +0100 --- src/version.c 2021-01-02 13:48:02.691043639 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2271, /**/ -- From "know your smileys": :^[/ mean-smiley-with-cigarette /// 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 ///