I have been seeing this problem for sometime, but haven't tried to
reproduce it stand-alone until now, so here is a simple script to show
the problem. If you source the below script, it will start showing
completion options once you type at least 3 characters, which is as
expected. The actual problem shows up when you start backing out. If you
press <BS>, Vim goes into "Whole line completion (^L^N^P)" mode and
shows results from insert-mode completion, instead of what has been set
with complete().
To reproduce,
- start gvim with -u NONE
- Add the below text:
wordone
wordtwo
- Source the following (you can copy and type :@* to do this easily)
aug TT
au!
au CursorMovedI * call TT()
aug END
function! TT()
let curword = expand('<cword>')
if strlen(curword) < 3
return
endif
call taglist('^xxxxxxx$')
let matches = map(['xxx', 'yyy', 'zzz'], 'curword.v:val')
call complete(col('.')-strlen(curword), [curword]+matches)
endfunction
- Open a new buffer (:new) and start typing "word" (without quotes) and
you will see completion options as
word
wordxxx
wordyyy
wordzzz
- Now press <BS>, the options change to:
wor
wordone
wordtwo
intead of:
worxxx
woryyy
worzzz
The problem can easily be observed if you have several buffers open in
the session (like say 100), as Vim starts scanning all buffers for
matches, when you press <BS>. You can actually cancel out using ^C, and
Vim will show the right completion matches, but if you don't press ^C
and wait for Vim to complete scanning, it will show insert-mode
completions.
--
Thank you,
Hari
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com