Loading ...
Sorry, an error occurred while loading the content.

Re: Mapping Bug (

Expand Messages
  • Andy Wokula
    ... Right, and it is important that Vim waits for foo_ to be completed. At any time, 6 mappings are involved (see below). I ll try again: ... nmap
    Message 1 of 4 , Mar 8, 2009
    • 0 Attachment
      Bram Moolenaar schrieb:
      >
      > Andy Wokula wrote:
      >
      >> A <script> mapping that produces a type ahead that Vim awaits
      >> completion for cannot be completed with a multi-byte key code.
      >> Script below:
      >>
      >> " Notes:
      >> " - This is quite a rare case, but bugging me for a long time ... at
      >> " least I think it deserves mentioning.
      >> " - For testing, the mappings will append Vim comments to the current
      >> " buffer.
      >> " - Either uncomment "OK Mapping" (mappings work as intended) or
      >> " "BUG Mapping" (mappings reveal a bug in Vim)
      >>
      >> " " OK Mapping:
      >> " nmap ff <SID>foo_
      >>
      >> " BUG Mapping:
      >> nmap <script> ff <SID>foo_
      >> " or :nnoremap <script> ff
      >>
      >>
      >> " press ffg
      >> " always ok
      >> nnoremap <SID>foo_g Go<C-U>" ok: ffg<Esc>
      >>
      >> " press ff<C-G> (single byte key code?)
      >> " always ok
      >> nnoremap <SID>foo_<C-G> Go<C-U>" ok: ff<lt>C-G><Esc>
      >>
      >> " press ff<F8> (multi byte key code?)
      >> " never executed with BUG Mapping:
      >> nnoremap <SID>foo_<F8> Go<C-U>" ok: ff<lt>F8><Esc>
      >>
      >> " instead, BUG Mapping executes the two mappings below:
      >>
      >> " press ff$
      >> " always ok
      >> " map that causes the timeout:
      >> nnoremap <SID>foo_ Go<C-U>" quit: ff<Esc>
      >>
      >> " press <F8>
      >> " always ok
      >> nnoremap <F8> Go<C-U>" <lt>F8><Esc>
      >
      > This is a bit confusing. Please give a reproducible example.
      > I suppose you have both "ff" and "ffg" mapped, so that after typing "ff"
      > Vim waits for the next character to find out what mapping applies.

      Right, and it is important that Vim waits for <SID>foo_ to be completed.
      At any time, 6 mappings are involved (see below).

      I'll try again:


      Script 1 (buggy):
      ----------
      nmap <script> ff <SID>foo_
      nnoremap <SID>foo_g Go<C-U>" ok: ffg<Esc>
      nnoremap <SID>foo_<C-G> Go<C-U>" ok: ff<lt>C-G><Esc>
      nnoremap <SID>foo_<F8> Go<C-U>" ok: ff<lt>F8><Esc>
      nnoremap <SID>foo_ Go<C-U>" quit: ff<Esc>
      nnoremap <F8> Go<C-U>" <lt>F8><Esc>
      ----------
      keys to type:
      ff<F8>
      bad result in the buffer:
      " quit: ff
      " <F8>


      Script 2 (ok):
      ----------
      nmap ff <SID>foo_
      nnoremap <SID>foo_g Go<C-U>" ok: ffg<Esc>
      nnoremap <SID>foo_<C-G> Go<C-U>" ok: ff<lt>C-G><Esc>
      nnoremap <SID>foo_<F8> Go<C-U>" ok: ff<lt>F8><Esc>
      nnoremap <SID>foo_ Go<C-U>" quit: ff<Esc>
      nnoremap <F8> Go<C-U>" <lt>F8><Esc>
      ----------
      keys to type:
      ff<F8>
      good result in the buffer:
      " ok: ff<F8>


      If you type ffg or ff<C-G> the results are good with
      both scripts:
      " ok: ffg
      " ok: ff<C-G>

      If you type ff (and wait) or ff$ (where $ is not mapped), you'll
      get in all cases (good result):
      " quit: ff

      > The Vim script you give suggests there also is a problem without
      > <script>, so are there two problems?

      Hmm, actually ... no. <script> is one of the conditions to show
      the problem.


      BTW: The following works ok (of course):
      ----------
      nmap <script> ff<F8> <SID>foo_<F8>
      nnoremap <SID>foo_<F8> Go<C-U>" ok: ff<lt>F8><Esc>
      ----------
      Here Vim waits for ff to be completed, not for <SID>foo_ .

      --
      Andy


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.