Hello I'm playing with complete() function, and I've found a bug in it.
Acording to :help complete, it says:
--------
inoremap <F5> <C-R>=ListMonths()<CR>
func! ListMonths()
call complete(col('.'), ['January', 'February', 'March',
\ 'April', 'May', 'June', 'July', 'August', 'September',
\ 'October', 'November', 'December'])
return ''
endfunc
This isn't very useful, but it shows how it works. Note that
an empty string is returned to avoid a zero being inserted.
--------
After loading this inoremap and function, and then I press F5 key,
it shows and selects a first row of the list as a default.
But sometimes when I press F5 again, it shows and selects a *second* row
of the list as a default.
How to reproduce:
<F5><C-P><C-E><F5>
I think this is a bug because the last <C-P> sets compl_direction variable
in edit.c to BACKWARD, and it is misused to build up a list for completion
on next complete() function call.
The attached file contains a simple patch to fix it.
# just one line, add 'compl_direction = FORWARD;'
... BTW, I need an extra feature for compelte() function.
The complete() function doesn't allow an element that is empty.
But, I want to show the elements have empty 'word', but non-empty 'abbr'.
so I proposed to add 'empty' key, like 'dup' key.
Bram, could you include this harmless feature, please? ;)
See the attached patch for more details.
It's very simple, and it doesn't change any default behavior.
Thanks in advance.
Best Regards,
Kikuchan
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
vim-complete-fix-and-allow-empty.patch
Description: vim-complete-fix-and-allow-empty.patch
