diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-02 13:53:59 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-02 13:53:59 +0100 |
commit | 3e0107ea16349b354e0e9712e95b09ef019e99e5 (patch) | |
tree | 03a5a0c54bbb1a242276646c6ff50e4cf3e09750 | |
parent | 38a434f7ba89ab2602019476219780e07fd8251f (diff) | |
download | vim-git-3e0107ea16349b354e0e9712e95b09ef019e99e5.tar.gz |
patch 8.2.2271: ml_get error when changing hidden buffer in Pythonv8.2.2271
Problem: ml_get error when changing hidden buffer in Python.
Solution: Block updating folds. (closes #7598)
-rw-r--r-- | src/evalbuffer.c | 6 | ||||
-rw-r--r-- | src/testdir/test_python3.vim | 33 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/evalbuffer.c b/src/evalbuffer.c index eabe626f5..376c1fe30 100644 --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -807,6 +807,9 @@ f_setline(typval_T *argvars, typval_T *rettv) 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,6 +824,9 @@ switch_buffer(bufref_T *save_curbuf, buf_T *buf) 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)) { diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim index 7765071b2..6afb76d9a 100644 --- a/src/testdir/test_python3.vim +++ b/src/testdir/test_python3.vim @@ -4016,4 +4016,37 @@ func Test_python3_non_utf8_string() sunmap <Esc>@ 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 diff --git a/src/version.c b/src/version.c index c1e79864a..d6e92b188 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2271, +/**/ 2270, /**/ 2269, |