vim-patch:8.2.2271: ml_get error when changing hidden buffer in Python (#40833)

Problem:    ml_get error when changing hidden buffer in Python.
Solution:   Block updating folds. (closes vim/vim#7598)

----

"ctx_switch()", "ctx_restore()" obsolete "switch_buffer()" and
"restore_buffer()".
Latter are unused since https://github.com/neovim/neovim/pull/15831.
Mark them as N/A (until some test fails).

----

3e0107ea16

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
Jan Edmund Lazo
2026-07-19 19:51:47 -04:00
committed by GitHub
parent 689b45dda3
commit d2a3e0e881
3 changed files with 35 additions and 27 deletions

View File

@@ -3672,4 +3672,37 @@ func Test_python3_keyboard_interrupt()
close!
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