ptr = ins_compl_get_next_word_or_line(st->ins_buf,
st->cur_match_pos, &len, &cont_s_ipos);
if (ptr == NULL || (ins_compl_has_preinsert()
- && STRCMP(ptr, compl_pattern.string) == 0))
+ && STRCMP(ptr, ins_compl_leader()) == 0))
continue;
if (is_nearest_active() && in_curbuf)
|| (compl_autocomplete && !ins_compl_has_preinsert());
int compl_fuzzy_match = (cur_cot_flags & COT_FUZZY) != 0;
int compl_preinsert = ins_compl_has_preinsert();
+ int has_autocomplete_delay = (compl_autocomplete && p_acl > 0);
// When user complete function return -1 for findstart which is next
// time of 'always', compl_shown_match become NULL.
// Insert the text of the new completion, or the compl_leader.
if (!started && ins_compl_preinsert_longest())
+ {
ins_compl_insert(TRUE, TRUE);
+ if (has_autocomplete_delay)
+ update_screen(0); // Show the inserted text right away
+ }
else if (compl_no_insert && !started && !compl_preinsert)
{
ins_compl_insert_bytes(compl_orig_text.string + get_compl_len(), -1);
// may undisplay the popup menu first
ins_compl_upd_pum();
- if (pum_enough_matches())
+ if (pum_enough_matches() && !has_autocomplete_delay)
// Will display the popup menu, don't redraw yet to avoid flicker.
pum_call_update_screen();
else
// inserted.
update_screen(0);
- // display the updated popup menu
- ins_compl_show_pum();
-#ifdef FEAT_GUI
- if (gui.in_use)
+ if (!has_autocomplete_delay)
{
- // Show the cursor after the match, not after the redrawn text.
- setcursor();
- out_flush_cursor(FALSE, FALSE);
- }
+ // display the updated popup menu
+ ins_compl_show_pum();
+#ifdef FEAT_GUI
+ if (gui.in_use)
+ {
+ // Show the cursor after the match, not after the redrawn text.
+ setcursor();
+ out_flush_cursor(FALSE, FALSE);
+ }
#endif
+ }
// Delete old text to be replaced, since we're still searching and
// don't want to match ourselves!
{
if (char_avail())
{
+ if (ins_compl_preinsert_effect()
+ && ins_compl_win_active(curwin))
+ {
+ ins_compl_delete(); // Remove pre-inserted text
+ compl_ins_end_col = compl_col;
+ }
ins_compl_restart();
compl_interrupted = TRUE;
break;
--- /dev/null
+|a+0&#ffffff0|u|t|o|c|o|m|p|l|e|t|e| @62
+|a|u|t|o|c|o|m|x@2| @64
+|a|u|t|o|c>o+0#00e0003&|m| +0#0000000&@67
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|1| @10|T|o|p|
--- /dev/null
+|a+0&#ffffff0|u|t|o|c|o|m|p|l|e|t|e| @62
+|a|u|t|o|c|o|m|x@2| @64
+|a|u|t|o|c>o+0#00e0003&|m| +0#0000000&@67
+|a+0#0000001#ffd7ff255|u|t|o|c|o|m|x@2| @4| +0#4040ff13#ffffff0@59
+|a+0#0000001#ffd7ff255|u|t|o|c|o|m|p|l|e|t|e| @2| +0#4040ff13#ffffff0@59
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|1| @10|T|o|p|
--- /dev/null
+|a+0&#ffffff0|u|t|o|c|o|m|p|l|e|t|e| @62
+|a|u|t|o|c|o|m|x@2| @64
+|a|u>t+0#00e0003&|o|c|o|m| +0#0000000&@67
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|1| @10|A|l@1|
--- /dev/null
+|a+0&#ffffff0|u|t|o|c|o|m|p|l|e|t|e| @62
+|a|u|t|o|c|o|m|x@2| @64
+|a|u>t+0#00e0003&|o|c|o|m| +0#0000000&@67
+|a+0#0000001#ffd7ff255|u|t|o|c|o|m|x@2| @4| +0#4040ff13#ffffff0@59
+|a+0#0000001#ffd7ff255|u|t|o|c|o|m|p|l|e|t|e| @2| +0#4040ff13#ffffff0@59
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|1| @10|A|l@1|
--- /dev/null
+|a+0&#ffffff0|u|t|o|c|o|m|p|l|e|t|e| @62
+|a|u|t|o|c|o|m|x@2| @64
+|a|u>t+0#00e0003&|o|c|o|m|p|l|e|t|e| +0#0000000&@62
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|1| @10|A|l@1|
--- /dev/null
+|a+0&#ffffff0|u|t|o|c|o|m|p|l|e|t|e| @62
+|a|u|t|o|c|o|m|x@2| @64
+|a|u>t+0#00e0003&|o|c|o|m|p|l|e|t|e| +0#0000000&@62
+|a+0#0000001#e0e0e08|u|t|o|c|o|m|p|l|e|t|e| @2| +0#4040ff13#ffffff0@59
+|a+0#0000001#ffd7ff255|u|t|o|c|o|m|x@2| @4| +0#4040ff13#ffffff0@59
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|1| @10|A|l@1|
call test_override("char_avail", 1)
new
inoremap <buffer><F5> <C-R>=GetLine()<CR>
- set completeopt=longest autocomplete
+ set completeopt+=longest autocomplete
call setline(1, ["foobar", "foozbar"])
call feedkeys("Go\<ESC>", 'tx')
call test_override("char_avail", 0)
endfunc
+func Test_autocompletedelay_longest_preinsert()
+ CheckScreendump
+ let lines =<< trim [SCRIPT]
+ call setline(1, ['autocomplete', 'autocomxxx'])
+ set autocomplete completeopt+=longest autocompletedelay=500
+ [SCRIPT]
+ call writefile(lines, 'XTest_autocompletedelay', 'D')
+ let buf = RunVimInTerminal('-S XTest_autocompletedelay', {'rows': 10})
+
+ " No spurious characters when autocompletedelay is in effect
+ call term_sendkeys(buf, "Goau")
+ sleep 10m
+ call term_sendkeys(buf, "toc")
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_1', {})
+ sleep 500m
+ call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_2', {})
+
+ " Deleting a char should still show longest text
+ call term_sendkeys(buf, "\<Esc>Saut")
+ sleep 10m
+ call term_sendkeys(buf, "\<BS>")
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_3', {})
+ sleep 500m
+ call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_4', {})
+
+ " Preinsert
+ call term_sendkeys(buf, "\<Esc>:set completeopt& completeopt+=preinsert\<CR>")
+
+ " Show preinserted text right away but display popup later
+ call term_sendkeys(buf, "\<Esc>Sau")
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_autocompletedelay_preinsert_1', {})
+ sleep 500m
+ call VerifyScreenDump(buf, 'Test_autocompletedelay_preinsert_2', {})
+
+ call term_sendkeys(buf, "\<esc>")
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1820,
/**/
1819,
/**/