)
did_cursorhold = FALSE;
+ // Check if we need to cancel completion mode because the window
+ // or tab page was changed
+ if (ins_compl_active() && !ins_compl_win_active(curwin))
+ ins_compl_cancel();
+
// If the cursor was moved we didn't just insert a space
if (arrow_used)
inserted_space = FALSE;
static int compl_cont_mode = 0;
static expand_T compl_xp;
+static win_T *compl_curr_win = NULL; // win where completion is active
+static buf_T *compl_curr_buf = NULL; // buf where completion is active
+
// List of flags for method of completion.
static int compl_cont_status = 0;
# define CONT_ADDING 1 // "normal" or "adding" expansion
compl_matches = 0;
compl_selected_item = -1;
compl_ins_end_col = 0;
+ compl_curr_win = NULL;
+ compl_curr_buf = NULL;
VIM_CLEAR_STRING(compl_pattern);
VIM_CLEAR_STRING(compl_leader);
edit_submode_extra = NULL;
* Return True when wp is the actual completion window
*/
int
-ins_compl_win_active(win_T *wp UNUSED)
+ins_compl_win_active(win_T *wp)
{
- return ins_compl_active()
-#if defined(FEAT_QUICKFIX)
- && (!wp->w_p_pvw
-# ifdef FEAT_PROP_POPUP
- && !(wp->w_popup_flags & POPF_INFO)
-# endif
- )
-#endif
- ;
+ return ins_compl_active() && wp == compl_curr_win
+ && wp->w_buffer == compl_curr_buf;
}
/*
return retval;
}
+/*
+ * Cancel completion.
+ */
+ int
+ins_compl_cancel(void)
+{
+ return ins_compl_stop(' ', ctrl_x_mode, TRUE);
+}
+
/*
* Prepare for Insert mode completion, or stop it.
* Called just after typing a character in Insert mode.
else if (insert_match && stop_arrow() == FAIL)
return FAIL;
+ compl_curr_win = curwin;
+ compl_curr_buf = curwin->w_buffer;
compl_shown_match = compl_curr_match;
compl_shows_dir = compl_direction;
void ins_compl_check_keys(int frequency, int in_compl_func);
int ins_complete(int c, int enable_pum);
void free_insexpand_stuff(void);
+int ins_compl_cancel(void);
/* vim: set ft=c : */
--- /dev/null
+|b+0&#ffffff0@1| |b@2| |b@1> @27||+1&&|a+0&&@1| |a@2| |a@1| @27
+|~+0#4040ff13&| @4| +0#0000001#e0e0e08|b@1| @12| +0#4040ff13#ffffff0@14||+1#0000000&|~+0#4040ff13&| @35
+|~| @4| +0#0000001#ffd7ff255|b@2| @11| +0#4040ff13#ffffff0@14||+1#0000000&|~+0#4040ff13&| @35
+|~| @4| +0#0000001#ffd7ff255|a@1| @12| +0#4040ff13#ffffff0@14||+1#0000000&|~+0#4040ff13&| @35
+|~| @4| +0#0000001#ffd7ff255|a@2| @11| +0#4040ff13#ffffff0@14||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|w+3#0000000&|i|n|_|b| |[|+|]| @9|1|,|1|0| @10|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|9| @11|A|l@1
+|-+2&&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@33
--- /dev/null
+|b+0&#ffffff0@1| |b@2| |b@1| @27||+1&&|a+0&&@1| |a@2| |a>a| @27
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|w+1#0000000&|i|n|_|b| |[|+|]| @9|1|,|1|0| @10|A|l@1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|9| @11|A|l@1
+|-+2&&@1| |I|N|S|E|R|T| |-@1| +0&&@62
--- /dev/null
+| +8#0000001#e0e0e08|[|N|o| |N|a|m|e|]| | +2#0000000#ffffff0|+| |[|N|o| |N|a|m|e|]| | +1&&@49|X+8#0000001#e0e0e08
+|a+0#0000000#ffffff0@1| |a@2| |a@1> @65
+|~+0#4040ff13&| @4| +0#0000001#e0e0e08|a@1| @12| +0#4040ff13#ffffff0@52
+|~| @4| +0#0000001#ffd7ff255|a@2| @11| +0#4040ff13#ffffff0@52
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |2| +0#0000000&@33
--- /dev/null
+| +2&#ffffff0|[|N|o| |N|a|m|e|]| | +8#0000001#e0e0e08|+| |[|N|o| |N|a|m|e|]| | +1#0000000#ffffff0@49|X+8#0000001#e0e0e08
+> +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|0|,|1| @10|A|l@1|
call StopVimInTerminal(buf)
endfunc
+func Test_pum_clear_when_switch_tab_or_win()
+ CheckScreendump
+
+ let lines =<< trim END
+ inoremap <F4> <Cmd>wincmd w<CR>
+ inoremap <F5> <Cmd>tabnext<CR>
+ END
+
+ call writefile(lines, 'Xtest', 'D')
+ let buf = RunVimInTerminal('-S Xtest', {})
+
+ call term_sendkeys(buf, ":tabe\<CR>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "Aaa aaa \<C-N>")
+ call VerifyScreenDump(buf, 'Test_tabnext_clear_pum_01', {})
+ call term_sendkeys(buf, "\<F5>")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_tabnext_clear_pum_02', {})
+ call term_sendkeys(buf, "\<ESC>:tabclose!\<CR>")
+
+ call term_sendkeys(buf, ":vnew win_b\<CR>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "Abb bbb \<C-N>")
+ call VerifyScreenDump(buf, 'Test_switchwin_clear_pum_01', {})
+ call term_sendkeys(buf, "\<F4>")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_switchwin_clear_pum_02', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1305,
/**/
1304,
/**/