> -----Original Message-----
> From: Benji Fisher [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 26, 2006 12:48 PM
> To: [email protected]
> Subject: Re: Vim70f crash - omnicompletion
>
> On Wed, Apr 26, 2006 at 11:18:35AM -0400, David Fishburn wrote:
> >
> > I am using vim70f on WinXP SP2.
> >
> > function! sqlcomplete#DrillIntoTable()
> > if pumvisible()
> > exec "normal! i\<C-Y>"
> > " call sqlcomplete#Map('column')
> > call feedkeys("\<C-X>\<C-O>")
> > endif
> > return ""
> > Endfunction
> >
> > imap <buffer> <c-right> <C-R>=sqlcomplete#DrillIntoTable()<CR>
> >
> > When the omni popup is visible, to get the current selected
> item you
> > must press <C-Y> while in insert mode (and the list visible). I am
> > trying to issue a <C-Y> from within my function. All
> attempts so far
> > have failed. My latest attempt is this line:
> > exec "normal! i\<C-Y>"
> >
> > As soon as the above line executes Vim crashes.
> >
> > So Bram, this is 2 things:
> > 1. A bug report.
> > 2. A question, how can I issue a <C-Y> from within a function
> > executing during an imap?
>
> 1. I can confirm the crash, slightly simplified:
>
> fun! DIT()
> if pumvisible()
> execute "normal! i\<C-Y>"
> endif
> return ""
> endfun
>
> imap <c-right> <C-R>=DIT()<CR>
>
> With the completion menu open, I type <C-Right><C-X><C-O> and
> gvim crashes. I get the same thing typing <C-R>=DIT()<CR>
> instead of using the mapping.
>
> 2. I think that what you want is something more along these lines:
>
> fun! DIT2()
> if pumvisible()
> return "\<C-Y>"
> else
> return ""
> endif
> endfun
>
> imap <F4> <C-R>=DIT2()<CR>
That will not work for me.
> > exec "normal! i\<C-Y>"
Since the user can navigate through the entries in the list before pressing
<C-Right>, I need to get the currently selected item before I redisplay the
popup with different values (based on what was highlighted).
> > " call sqlcomplete#Map('column')
> > call feedkeys("\<C-X>\<C-O>")
So after a issue a <C-Y> on behalf of the user, I setup the SQL completion
plugin for the next step and trigger omni again using the new feedkeys()
function. According to the docs feedkeys() will executes the keys once the
function completes.
So as I was typing this up I just realized I can code this as follows:
function! sqlcomplete#DrillIntoTable()
if pumvisible()
call sqlcomplete#Map('column')
call feedkeys("\<C-Y>\<C-X>\<C-O>")
else
exec "normal! \<C-Right>"
endif
return ""
Endfunction
Since I technically do not need to hit the <C-Y> prior to calling into
sqlcomplete#Map. So the code works as is, and avoids the crash.
But for future developers, I could see a need to be able to retrieve the
currently selected item in the popup, so the question stands although it is
moved way down my priority list.
Thanks for the response Benji, and leading me in the right direction.
Dave