Saturday, October 22, 2016

A problem (bug?) with = and remapping

Hello,
I have a problem with a plugin I am writing. To reproduce, define
`keysequence.vim` with this content:

let s:keys = ["\<c-c>s", "\<c-c>k"]

fun! KeySequence(i)
return
s:keys[a:i]."\<c-r>=pumvisible()?'':KeySequence(".(a:i+1).")\<cr>"
endf

imap <expr> <tab> KeySequence(0)

Then:

vim -N -u NONE
:filetype on
:filetype plugin on
:syntax on
:set ft=sql
:source keysequence.vim
:set completeopt+=menuone

and type:

ocr<tab> ta<tab>

The first <tab> correctly completes the keyword using <c-c>s, but the
second does not. The second <tab> is remapped to

<c-c>s<c-r>=pumvisible()?'':KeySequence(1)<cr>

and since <c-c>s does not return any result, KeySequence(1) is called
and <c-c>k is typed. But this latter <c-c> is not remapped, causing Vim
to exit Insert mode and go up one line (because of `k`).

Why isn't the second `<c-c>` remapped?

Life.

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: