Hi,

I'm currently struggling to write a unit test for a mapping that analyses the 
current line.

I've actually two mappings 
  <  that inserts <|>   (| being where the cursor ends up)
  >  that replaces <|> with &gt;
     or that moves the cursor after the > character, in *|>
     or that inserts >

When I test with either

  normal o<foo>bar
or
  call feedkeys('o<foo>bar', 'x')

I end up with "<fo&gt;bar" because when > mapping is triggered, what was 
previously injected isn't here yet: getline('.') returns "<>", without the 
"foo" part.

If I force a break before the <, it works well
  call feedkeys("o<foo\<esc>a>bar", 'x')


I suspect there is way to have a simple key sequence: indeed, when I use my 
complete environment (vimrc & plugins), 'o<foo>bar' is enough. With a clean '-u 
NONE' environment, I cannot make it work. Impossible to find what makes the 
difference in the thousands lines of extra-configuration.

A simplified (non-redoable, with less cases) version of the mappings would be

   inoremap        < <><left>
   inoremap <expr> > getline('.')[col('.')-2:col('.')-1]=='<>' ? 
'<del><bs>&gt;' : '<right>'


Does anybody know what setting (or feedkeys() flags?) permits to have a 
behaviour that really matches what happens when we type the exact same keys?
Or do we have no choices but to test more atomic sequences?

-- 
Luc Hermitte

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/2039254040.-606058657.1591183790039.JavaMail.root%40zimbra60-e10.priv.proxad.net.

Raspunde prin e-mail lui