To: vim_dev@googlegroups.com Subject: Patch 7.4.2146 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2146 Problem: Not enough testing for popup menu. CTRL-E does not always work properly. Solution: Add more tests. When using CTRL-E check if the popup menu is visible. (Christian Brabandt) Files: src/edit.c, src/testdir/test_popup.vim *** ../vim-7.4.2145/src/edit.c 2016-07-24 21:58:39.692057745 +0200 --- src/edit.c 2016-08-02 21:57:52.403664971 +0200 *************** *** 3891,3898 **** && pum_visible()) retval = TRUE; ! /* CTRL-E means completion is Ended, go back to the typed text. */ ! if (c == Ctrl_E) { ins_compl_delete(); if (compl_leader != NULL) --- 3891,3899 ---- && pum_visible()) retval = TRUE; ! /* CTRL-E means completion is Ended, go back to the typed text. ! * but only do this, if the Popup is still visible */ ! if (c == Ctrl_E && pum_visible()) { ins_compl_delete(); if (compl_leader != NULL) *** ../vim-7.4.2145/src/testdir/test_popup.vim 2016-07-09 21:57:16.630640033 +0200 --- src/testdir/test_popup.vim 2016-08-02 22:00:15.382332313 +0200 *************** *** 3,16 **** let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] let g:setting = '' ! func ListMonths() ! if g:setting != '' ! exe ":set" g:setting ! endif ! call complete(col('.'), g:months) ! return '' endfunc func! Test_popup_completion_insertmode() new inoremap =ListMonths() --- 3,211 ---- let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] let g:setting = '' ! func! ListMonths() ! if g:setting != '' ! exe ":set" g:setting ! endif ! let mth=copy(g:months) ! let entered = strcharpart(getline('.'),0,col('.')) ! if !empty(entered) ! let mth=filter(mth, 'v:val=~"^".entered') ! endif ! call complete(1, mth) ! return '' endfunc + func! Test_popup_complete() + new + inoremap =ListMonths() + + " - select original typed text before the completion started + call feedkeys("aJu\\\\", 'tx') + call assert_equal(["Ju"], getline(1,2)) + %d + + " - accept current match + call feedkeys("a\". repeat("\",7). "\\", 'tx') + call assert_equal(["August"], getline(1,2)) + %d + + " - Delete one character from the inserted text (state: 1) + " TODO: This should not end the completion, but it does. + " This should according to the documentation: + " January + " but instead, this does + " Januar + " (idea is, C-L inserts the match from the popup menu + " but if the menu is closed, it will insert the character + call feedkeys("aJ\\\\", 'tx') + call assert_equal(["Januar "], getline(1,2)) + %d + + " any-non special character: Stop completion without changing the match + " and insert the typed character + call feedkeys("a\20", 'tx') + call assert_equal(["January20"], getline(1,2)) + %d + + " any-non printable, non-white character: Add this character and + " reduce number of matches + call feedkeys("aJu\\l\", 'tx') + call assert_equal(["Jul"], getline(1,2)) + %d + + " any-non printable, non-white character: Add this character and + " reduce number of matches + call feedkeys("aJu\\l\\", 'tx') + call assert_equal(["July"], getline(1,2)) + %d + + " any-non printable, non-white character: Add this character and + " reduce number of matches + call feedkeys("aJu\\l\", 'tx') + call assert_equal(["Jul"], getline(1,2)) + %d + + " - Delete one character from the inserted text (state: 2) + call feedkeys("a\\\", 'tx') + call assert_equal(["Februar"], getline(1,2)) + %d + + " - Insert one character from the current match + call feedkeys("aJ\".repeat("\",3)."\\", 'tx') + call assert_equal(["J "], getline(1,2)) + %d + + " - Insert one character from the current match + call feedkeys("aJ\".repeat("\",4)."\\", 'tx') + call assert_equal(["January "], getline(1,2)) + %d + + " - Accept current selected match + call feedkeys("aJ\\\", 'tx') + call assert_equal(["January"], getline(1,2)) + %d + + " - End completion, go back to what was there before selecting a match + call feedkeys("aJu\\\", 'tx') + call assert_equal(["Ju"], getline(1,2)) + %d + + " - Select a match several entries back + call feedkeys("a\\\\", 'tx') + call assert_equal([""], getline(1,2)) + %d + + " - Select a match several entries back + call feedkeys("a\\\\\", 'tx') + call assert_equal(["December"], getline(1,2)) + %d + + " - Select a match several entries back + call feedkeys("a\\\\\\", 'tx') + call assert_equal(["February"], getline(1,2)) + %d + + " - Select a match several entries further + call feedkeys("a\\\\", 'tx') + call assert_equal(["November"], getline(1,2)) + %d + + " - Select a match several entries further + call feedkeys("a\\\\\", 'tx') + call assert_equal(["December"], getline(1,2)) + %d + + " - Select a match several entries further + call feedkeys("a\\\\\\", 'tx') + call assert_equal([""], getline(1,2)) + %d + + " - Select a match several entries further + call feedkeys("a\".repeat("\",4)."\\", 'tx') + call assert_equal(["October"], getline(1,2)) + %d + + " - Select a match don't insert yet + call feedkeys("a\\\\", 'tx') + call assert_equal([""], getline(1,2)) + %d + + " - Select a match don't insert yet + call feedkeys("a\\\\\", 'tx') + call assert_equal(["December"], getline(1,2)) + %d + + " - Select a match don't insert yet + call feedkeys("a\\\\\\", 'tx') + call assert_equal(["November"], getline(1,2)) + %d + + " - Stop completion and insert the match + call feedkeys("a\\\\", 'tx') + call assert_equal(["January "], getline(1,2)) + %d + + " - Stop completion and insert the match + call feedkeys("a\".repeat("\",5)." \", 'tx') + call assert_equal(["September "], getline(1,2)) + %d + + " - Use the text and insert line break (state: 1) + call feedkeys("a\\\", 'tx') + call assert_equal(["January", ''], getline(1,2)) + %d + + " - Insert the current selected text (state: 2) + call feedkeys("a\".repeat("\",5)."\\", 'tx') + call assert_equal(["September"], getline(1,2)) + %d + + " Insert match immediately, if there is only one match + " selects a character from the line above + call append(0, ["December2015"]) + call feedkeys("aD\\\\\\\", 'tx') + call assert_equal(["December2015", "December2015", ""], getline(1,3)) + %d + + " Insert match immediately, if there is only one match + " Should select a character from the line below + call append(1, ["December2015"]) + :1 + call feedkeys("aD\\\\\\\", 'tx') + call assert_equal(["December2015", "", "December2015"], getline(1,3)) + %d + + " use menuone for 'completeopt' + " Since for the first the menu is still shown, will only select + " three letters from the line above + set completeopt&vim + set completeopt+=menuone + call append(0, ["December2015"]) + call feedkeys("aD\\\\\\\", 'tx') + call assert_equal(["December2015", "December201", ""], getline(1,3)) + %d + + " use longest for 'completeopt' + set completeopt&vim + call feedkeys("aM\\\\\\", 'tx') + set completeopt+=longest + call feedkeys("aM\\\\\\", 'tx') + call assert_equal(["M", "Ma", ""], getline(1,3)) + %d + + " use noselect/noinsert for 'completeopt' + set completeopt&vim + call feedkeys("aM\\\", 'tx') + set completeopt+=noselect + call feedkeys("aM\\\", 'tx') + set completeopt-=noselect completeopt+=noinsert + call feedkeys("aM\\\", 'tx') + call assert_equal(["March", "M", "March"], getline(1,4)) + %d + endfu + + func! Test_popup_completion_insertmode() new inoremap =ListMonths() *************** *** 18,35 **** --- 213,234 ---- call feedkeys("a\\\\", 'tx') call assert_equal('February', getline(1)) %d + " Set noinsertmode let g:setting = 'noinsertmode' call feedkeys("a\\\\", 'tx') call assert_equal('February', getline(1)) call assert_false(pumvisible()) %d + " Go through all matches, until none is selected let g:setting = '' call feedkeys("a\". repeat("\",12)."\\", 'tx') call assert_equal('', getline(1)) %d + " select previous entry call feedkeys("a\\\\", 'tx') call assert_equal('', getline(1)) %d + " select last entry call feedkeys("a\\\\\", 'tx') call assert_equal('December', getline(1)) *************** *** 66,68 **** --- 265,269 ---- call complete(1, ['source', 'soundfold']) return '' endfunction + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-7.4.2145/src/version.c 2016-08-02 21:55:14.413138582 +0200 --- src/version.c 2016-08-02 22:35:49.446308590 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2146, /**/ -- ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot. King of all Britons, defeator of the Saxons, sovereign of all England! [Pause] SOLDIER: Get away! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///