summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-02-09 15:06:02 +0100
committerBram Moolenaar <Bram@vim.org>2018-02-09 15:06:02 +0100
commit02ae9b4a93deea4993d7abe20485f91f1cce5e36 (patch)
treec6a08def7fcc005f500d2914a09b3fa3638d1143
parent1567558b20575e1b17c3808c6bd622b0b4810e36 (diff)
patch 8.0.1482: using feedkeys() does not work to test completionv8.0.1482
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.
-rw-r--r--src/edit.c19
-rw-r--r--src/testdir/test_edit.vim7
-rw-r--r--src/testdir/test_ins_complete.vim11
-rw-r--r--src/testdir/test_popup.vim2
-rw-r--r--src/version.c2
5 files changed, 27 insertions, 14 deletions
diff --git a/src/edit.c b/src/edit.c
index 863f1cb68d..fa1d84bbc7 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1454,7 +1454,8 @@ doESCkey:
/* if 'complete' is empty then plain ^P is no longer special,
* but it is under other ^X modes */
if (*curbuf->b_p_cpt == NUL
- && ctrl_x_mode != 0
+ && (ctrl_x_mode == CTRL_X_NORMAL
+ || ctrl_x_mode == CTRL_X_WHOLE_LINE)
&& !(compl_cont_status & CONT_LOCAL))
goto normalchar;
@@ -1568,8 +1569,8 @@ normalchar:
/* If typed something may trigger CursorHoldI again. */
if (c != K_CURSORHOLD
# ifdef FEAT_COMPL_FUNC
- /* but not in CTRL-X mode, a script can't restore the state */
- && ctrl_x_mode == 0
+ /* but not in CTRL-X mode, a script can't restore the state */
+ && ctrl_x_mode == CTRL_X_NORMAL
# endif
)
did_cursorhold = FALSE;
@@ -1582,7 +1583,7 @@ normalchar:
#ifdef FEAT_CINDENT
if (can_cindent && cindent_on()
# ifdef FEAT_INS_EXPAND
- && ctrl_x_mode == 0
+ && ctrl_x_mode == CTRL_X_NORMAL
# endif
)
{
@@ -5020,12 +5021,12 @@ ins_compl_next(
ins_compl_check_keys(int frequency, int in_compl_func)
{
static int count = 0;
+ int c;
- int c;
-
- /* Don't check when reading keys from a script. That would break the test
- * scripts */
- if (using_script())
+ /* Don't check when reading keys from a script, :normal or feedkeys().
+ * That would break the test scripts. But do check for keys when called
+ * from complete_check(). */
+ if (!in_compl_func && (using_script() || ex_normal_busy))
return;
/* Only do this at regular intervals */
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index f857516e88..7278bcd85d 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -631,11 +631,11 @@ func! Test_edit_CTRL_L()
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<esc>", 'tnix')
call assert_equal(['one', 'two', 'three', 't', '', '', ''], getline(1, '$'))
call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<esc>", 'tnix')
- call assert_equal(['one', 'two', 'three', 't', '', '', ''], getline(1, '$'))
- call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
call assert_equal(['one', 'two', 'three', 'two', '', '', ''], getline(1, '$'))
- call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
+ call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
call assert_equal(['one', 'two', 'three', 'three', '', '', ''], getline(1, '$'))
+ call feedkeys("cct\<c-x>\<c-l>\<c-n>\<c-n>\<c-n>\<c-n>\<esc>", 'tnix')
+ call assert_equal(['one', 'two', 'three', 't', '', '', ''], getline(1, '$'))
call feedkeys("cct\<c-x>\<c-l>\<c-p>\<esc>", 'tnix')
call assert_equal(['one', 'two', 'three', 'two', '', '', ''], getline(1, '$'))
call feedkeys("cct\<c-x>\<c-l>\<c-p>\<c-p>\<esc>", 'tnix')
@@ -1357,7 +1357,6 @@ func Test_edit_complete_very_long_name()
let save_columns = &columns
" Need at least about 1100 columns to reproduce the problem.
set columns=2000
- call assert_equal(2000, &columns)
set noswapfile
let longfilename = longdirname . '/' . repeat('a', 255)
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index e57782fb87..652b1d9e42 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -116,3 +116,14 @@ func Test_omni_dash()
delfunc Omni
set omnifunc=
endfunc
+
+" Check that when using feedkeys() typeahead does not interrupt searching for
+" completions.
+func Test_compl_feedkeys()
+ new
+ set completeopt=menuone,noselect
+ call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "tx")
+ call assert_equal("jump jump", getline(1))
+ bwipe!
+ set completeopt&
+endfunc
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index 6250c1b8f2..d121affc7d 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -693,7 +693,7 @@ func Test_popup_and_preview_autocommand()
norm! gt
call assert_equal(0, &previewwindow)
norm! gT
- call assert_equal(12, tabpagenr('$'))
+ call assert_equal(10, tabpagenr('$'))
tabonly
pclose
augroup MyBufAdd
diff --git a/src/version.c b/src/version.c
index 0e282ab4f8..5285565871 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1482,
+/**/
1481,
/**/
1480,