Skip to content

Commit 02ae9b4

Browse files
committed
patch 8.0.1482: using feedkeys() does not work to test completion
Problem: Using feedkeys() does not work to test Insert mode completion. (Lifepillar) Solution: Do not check for typed keys when executing :normal or feedkeys(). Fix thesaurus completion not working when 'complete' is empty.
1 parent 1567558 commit 02ae9b4

5 files changed

Lines changed: 27 additions & 14 deletions

File tree

src/edit.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,8 @@ edit(
14541454
/* if 'complete' is empty then plain ^P is no longer special,
14551455
* but it is under other ^X modes */
14561456
if (*curbuf->b_p_cpt == NUL
1457-
&& ctrl_x_mode != 0
1457+
&& (ctrl_x_mode == CTRL_X_NORMAL
1458+
|| ctrl_x_mode == CTRL_X_WHOLE_LINE)
14581459
&& !(compl_cont_status & CONT_LOCAL))
14591460
goto normalchar;
14601461

@@ -1568,8 +1569,8 @@ edit(
15681569
/* If typed something may trigger CursorHoldI again. */
15691570
if (c != K_CURSORHOLD
15701571
# ifdef FEAT_COMPL_FUNC
1571-
/* but not in CTRL-X mode, a script can't restore the state */
1572-
&& ctrl_x_mode == 0
1572+
/* but not in CTRL-X mode, a script can't restore the state */
1573+
&& ctrl_x_mode == CTRL_X_NORMAL
15731574
# endif
15741575
)
15751576
did_cursorhold = FALSE;
@@ -1582,7 +1583,7 @@ edit(
15821583
#ifdef FEAT_CINDENT
15831584
if (can_cindent && cindent_on()
15841585
# ifdef FEAT_INS_EXPAND
1585-
&& ctrl_x_mode == 0
1586+
&& ctrl_x_mode == CTRL_X_NORMAL
15861587
# endif
15871588
)
15881589
{
@@ -5020,12 +5021,12 @@ ins_compl_next(
50205021
ins_compl_check_keys(int frequency, int in_compl_func)
50215022
{
50225023
static int count = 0;
5024+
int c;
50235025

5024-
int c;
5025-
5026-
/* Don't check when reading keys from a script. That would break the test
5027-
* scripts */
5028-
if (using_script())
5026+
/* Don't check when reading keys from a script, :normal or feedkeys().
5027+
* That would break the test scripts. But do check for keys when called
5028+
* from complete_check(). */
5029+
if (!in_compl_func && (using_script() || ex_normal_busy))
50295030
return;
50305031

50315032
/* Only do this at regular intervals */

src/testdir/test_edit.vim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,11 +631,11 @@ func! Test_edit_CTRL_L()
631631
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<esc>", 'tnix')
632632
call assert_equal(['one', 'two', 'three', 't', '', '', ''], getline(1, '$'))
633633
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<esc>", 'tnix')
634-
call assert_equal(['one', 'two', 'three', 't', '', '', ''], getline(1, '$'))
635-
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
636634
call assert_equal(['one', 'two', 'three', 'two', '', '', ''], getline(1, '$'))
637-
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
635+
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
638636
call assert_equal(['one', 'two', 'three', 'three', '', '', ''], getline(1, '$'))
637+
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
638+
call assert_equal(['one', 'two', 'three', 't', '', '', ''], getline(1, '$'))
639639
call feedkeys("cct\<c-x>\<c-l>\<c-p>\<esc>", 'tnix')
640640
call assert_equal(['one', 'two', 'three', 'two', '', '', ''], getline(1, '$'))
641641
call feedkeys("cct\<c-x>\<c-l>\<c-p>\<c-p>\<esc>", 'tnix')
@@ -1357,7 +1357,6 @@ func Test_edit_complete_very_long_name()
13571357
let save_columns = &columns
13581358
" Need at least about 1100 columns to reproduce the problem.
13591359
set columns=2000
1360-
call assert_equal(2000, &columns)
13611360
set noswapfile
13621361

13631362
let longfilename = longdirname . '/' . repeat('a', 255)

src/testdir/test_ins_complete.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,14 @@ func Test_omni_dash()
116116
delfunc Omni
117117
set omnifunc=
118118
endfunc
119+
120+
" Check that when using feedkeys() typeahead does not interrupt searching for
121+
" completions.
122+
func Test_compl_feedkeys()
123+
new
124+
set completeopt=menuone,noselect
125+
call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "tx")
126+
call assert_equal("jump jump", getline(1))
127+
bwipe!
128+
set completeopt&
129+
endfunc

src/testdir/test_popup.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func Test_popup_and_preview_autocommand()
693693
norm! gt
694694
call assert_equal(0, &previewwindow)
695695
norm! gT
696-
call assert_equal(12, tabpagenr('$'))
696+
call assert_equal(10, tabpagenr('$'))
697697
tabonly
698698
pclose
699699
augroup MyBufAdd

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1482,
774776
/**/
775777
1481,
776778
/**/

0 commit comments

Comments
 (0)