diff src/testdir/test_python3.vim @ 28950:44481ae7c7ce v8.2.4997

patch 8.2.4997: Python: changing hidden buffer can cause display mess up Commit: https://github.com/vim/vim/commit/37233f6022b3ed16985a91d22752b3ca162e21d0 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 22 12:23:48 2022 +0100 patch 8.2.4997: Python: changing hidden buffer can cause display mess up Problem: Python: changing hidden buffer can cause the display to be messed up. Solution: Do not mark changed lines when using another buffer. (Paul Ollis, closes #10437, closes #7972)
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 May 2022 13:30:03 +0200
parents 485c7c4afeb7
children b9b8422ad671
line wrap: on
line diff
--- a/src/testdir/test_python3.vim
+++ b/src/testdir/test_python3.vim
@@ -4061,4 +4061,40 @@ func Test_python3_fold_hidden_buffer()
   bwipe! Xa.txt
 endfunc
 
+" Test to catch regression fix #10437.
+func Test_python3_hidden_buf_mod_does_not_mess_up_display()
+  CheckRunVimInTerminal
+
+  let testfile = 'Xtest.vim'
+  let lines =<< trim END
+        set hidden number
+        new
+        hide
+        sil call setline(1, repeat(['aaa'], &lines) + ['bbbbbb'])
+        fu Func()
+        python3 << EOF
+        import vim
+        b = vim.buffers[2]
+        b[:] = ['', '']
+        EOF
+        endfu
+        norm! Gzb
+        call feedkeys(":call Func()\r", 'n')
+  END
+  call writefile(lines, testfile)
+
+  let rows = 10
+  let bufnr = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
+  call TermWait(bufnr, 100)
+  call assert_equal('run', job_status(term_getjob(bufnr)))
+  let g:test_is_flaky = 0
+  call WaitForAssert({-> assert_match('^  3 aaa$', term_getline(bufnr, 1))})
+  call WaitForAssert({-> assert_match('^ 11 bbbbbb$', term_getline(bufnr, rows - 1))})
+
+  call term_sendkeys(bufnr, ":qall!\<CR>")
+  call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(bufnr)))})
+  exe bufnr . 'bwipe!'
+  call delete(testfile)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab