To: vim_dev@googlegroups.com Subject: Patch 8.2.4997 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4997 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) Files: src/if_py_both.h, src/testdir/test_python3.vim *** ../vim-8.2.4996/src/if_py_both.h 2022-05-12 20:35:32.327574779 +0100 --- src/if_py_both.h 2022-05-22 12:15:45.355259874 +0100 *************** *** 4676,4684 **** // Only adjust marks if we managed to switch to a window that holds // the buffer, otherwise line numbers will be invalid. if (save_curbuf.br_buf == NULL) mark_adjust((linenr_T)lo, (linenr_T)(hi - 1), (long)MAXLNUM, (long)extra); ! changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra); if (buf == curbuf && (switchwin.sw_curwin != NULL || save_curbuf.br_buf == NULL)) --- 4676,4686 ---- // Only adjust marks if we managed to switch to a window that holds // the buffer, otherwise line numbers will be invalid. if (save_curbuf.br_buf == NULL) + { mark_adjust((linenr_T)lo, (linenr_T)(hi - 1), (long)MAXLNUM, (long)extra); ! changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra); ! } if (buf == curbuf && (switchwin.sw_curwin != NULL || save_curbuf.br_buf == NULL)) *** ../vim-8.2.4996/src/testdir/test_python3.vim 2021-11-21 11:35:59.456938797 +0000 --- src/testdir/test_python3.vim 2022-05-22 12:21:18.739534931 +0100 *************** *** 4061,4064 **** --- 4061,4100 ---- 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!\") + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(bufnr)))}) + exe bufnr . 'bwipe!' + call delete(testfile) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4996/src/version.c 2022-05-22 11:59:20.527602615 +0100 --- src/version.c 2022-05-22 12:18:37.451430361 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 4997, /**/ -- Did you hear about the new 3 million dollar West Virginia State Lottery? The winner gets 3 dollars a year for a million years. /// 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 ///