To: vim_dev@googlegroups.com Subject: Patch 8.0.1805 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1806 Problem: InsertCharPre causes problems for autocomplete. (Lifepillar) Solution: Check for InsertCharPre before calling vpeekc(). (Christian Brabandt, closes #2876) Files: src/edit.c, src/testdir/test_popup.vim *** ../vim-8.0.1805/src/edit.c 2018-04-26 22:30:29.226565612 +0200 --- src/edit.c 2018-05-08 22:41:35.501074620 +0200 *************** *** 6185,6190 **** --- 6185,6192 ---- * 'paste' is set).. * Don't do this when there an InsertCharPre autocommand is defined, * because we need to fire the event for every character. + * Do the check for InsertCharPre before the call to vpeekc() because the + * InsertCharPre autocommand could change the input buffer. */ #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; /* allow scrolling here */ *************** *** 6194,6199 **** --- 6196,6202 ---- #ifdef FEAT_MBYTE && (!has_mbyte || (*mb_char2len)(c) == 1) #endif + && !has_insertcharpre() && vpeekc() != NUL && !(State & REPLACE_FLAG) #ifdef FEAT_CINDENT *************** *** 6202,6208 **** #ifdef FEAT_RIGHTLEFT && !p_ri #endif ! && !has_insertcharpre()) { #define INPUT_BUFLEN 100 char_u buf[INPUT_BUFLEN + 1]; --- 6205,6211 ---- #ifdef FEAT_RIGHTLEFT && !p_ri #endif ! ) { #define INPUT_BUFLEN 100 char_u buf[INPUT_BUFLEN + 1]; *** ../vim-8.0.1805/src/testdir/test_popup.vim 2018-04-30 14:28:20.448618066 +0200 --- src/testdir/test_popup.vim 2018-05-08 22:37:19.834862874 +0200 *************** *** 831,834 **** --- 831,864 ---- bwipe! endfunc + fun! Test_complete_o_tab() + let s:o_char_pressed = 0 + + fun! s:act_on_text_changed() + if s:o_char_pressed + let s:o_char_pressed = 0 + call feedkeys("\\", 'i') + endif + endf + + set completeopt=menu,noselect + new + imap pumvisible() ? "\" : "X" + autocmd! InsertCharPre let s:o_char_pressed = (v:char ==# 'o') + autocmd! TextChangedI call act_on_text_changed() + call setline(1, ['hoard', 'hoax', 'hoarse', '']) + let l:expected = ['hoard', 'hoax', 'hoarse', 'hoax', 'hoax'] + call cursor(4,1) + call test_override("char_avail", 1) + call feedkeys("Ahoa\\\\", 'tx') + call feedkeys("oho\\\\", 'tx') + call assert_equal(l:expected, getline(1,'$')) + + call test_override("char_avail", 0) + bwipe! + set completeopt& + delfunc s:act_on_text_changed + endf + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.0.1805/src/version.c 2018-05-08 22:31:32.769389714 +0200 --- src/version.c 2018-05-08 22:40:35.957487297 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1806, /**/ -- LAUNCELOT: I am, sir. I am a Knight of King Arthur. FATHER: 'Mm ... very nice castle, Camelot ... very good pig country.... "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 ///