To: vim_dev@googlegroups.com Subject: Patch 8.2.2427 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2427 Problem: Can still switch windows for 'completefunc'. Solution: Also disallow switching windows for other completions. Files: src/insexpand.c, src/testdir/test_ins_complete.vim, src/testdir/test_popup.vim *** ../vim-8.2.2426/src/insexpand.c 2021-01-29 21:07:03.995298849 +0100 --- src/insexpand.c 2021-01-29 21:38:32.524194427 +0100 *************** *** 121,127 **** static char e_hitend[] = N_("Hit end of paragraph"); # ifdef FEAT_COMPL_FUNC - static char e_complwin[] = N_("E839: Completion function changed window"); static char e_compldel[] = N_("E840: Completion function deleted text"); # endif --- 121,126 ---- *************** *** 2199,2206 **** typval_T args[3]; char_u *funcname; pos_T pos; - win_T *curwin_save; - buf_T *curbuf_save; typval_T rettv; int save_State = State; --- 2198,2203 ---- *************** *** 2216,2223 **** args[2].v_type = VAR_UNKNOWN; pos = curwin->w_cursor; - curwin_save = curwin; - curbuf_save = curbuf; // Lock the text to avoid weird things from happening. Also disallow // switching to another window, it should not be needed and may end up in // Insert mode in another buffer. --- 2213,2218 ---- *************** *** 2246,2256 **** } --textwinlock; - if (curwin_save != curwin || curbuf_save != curbuf) - { - emsg(_(e_complwin)); - goto theend; - } curwin->w_cursor = pos; // restore the cursor position validate_cursor(); if (!EQUAL_POS(curwin->w_cursor, pos)) --- 2241,2246 ---- *************** *** 3843,3850 **** int col; char_u *funcname; pos_T pos; - win_T *curwin_save; - buf_T *curbuf_save; int save_State = State; // Call 'completefunc' or 'omnifunc' and get pattern length as a --- 3833,3838 ---- *************** *** 3866,3881 **** args[1].vval.v_string = (char_u *)""; args[2].v_type = VAR_UNKNOWN; pos = curwin->w_cursor; ! curwin_save = curwin; ! curbuf_save = curbuf; col = call_func_retnr(funcname, 2, args); State = save_State; - if (curwin_save != curwin || curbuf_save != curbuf) - { - emsg(_(e_complwin)); - return FAIL; - } curwin->w_cursor = pos; // restore the cursor position validate_cursor(); if (!EQUAL_POS(curwin->w_cursor, pos)) --- 3854,3864 ---- args[1].vval.v_string = (char_u *)""; args[2].v_type = VAR_UNKNOWN; pos = curwin->w_cursor; ! ++textwinlock; col = call_func_retnr(funcname, 2, args); + --textwinlock; State = save_State; curwin->w_cursor = pos; // restore the cursor position validate_cursor(); if (!EQUAL_POS(curwin->w_cursor, pos)) *** ../vim-8.2.2426/src/testdir/test_ins_complete.vim 2021-01-29 21:07:03.995298849 +0100 --- src/testdir/test_ins_complete.vim 2021-01-29 21:32:07.633856753 +0100 *************** *** 548,554 **** endfunc set completefunc=CompleteFunc call setline(1, ['', 'abcd', '']) ! call assert_fails('exe "normal 2G$a\\"', 'E840:') " delete text when called for the second time func CompleteFunc2(findstart, base) --- 548,554 ---- endfunc set completefunc=CompleteFunc call setline(1, ['', 'abcd', '']) ! call assert_fails('exe "normal 2G$a\\"', 'E578:') " delete text when called for the second time func CompleteFunc2(findstart, base) *** ../vim-8.2.2426/src/testdir/test_popup.vim 2021-01-29 21:07:03.995298849 +0100 --- src/testdir/test_popup.vim 2021-01-29 21:35:58.457016985 +0100 *************** *** 367,377 **** setlocal completefunc=DummyCompleteTwo call setline(1, 'two') /^two ! call assert_fails('call feedkeys("A\\\\", "x")', 'E839:') ! call assert_notequal(winid, win_getid()) ! q! call assert_equal(winid, win_getid()) ! call assert_equal('two', getline(1)) q! endfunc --- 367,375 ---- setlocal completefunc=DummyCompleteTwo call setline(1, 'two') /^two ! call assert_fails('call feedkeys("A\\\\", "x")', 'E565:') call assert_equal(winid, win_getid()) ! call assert_equal('twodef', getline(1)) q! endfunc *** ../vim-8.2.2426/src/version.c 2021-01-29 21:07:03.995298849 +0100 --- src/version.c 2021-01-29 21:27:14.010899657 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2427, /**/ -- XML is a nice language for computers. Not for humans. /// 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 ///