Lifepillar wrote: > On 05/02/2018 22:49, Nikolay Aleksandrovich Pavlov wrote: > > 2018-02-05 23:31 GMT+03:00 Lifepillar <lifepil...@lifepillar.me>: > >> I would like to automate the testing of my completion plugin, > >> so I have started to write functions like this (I am using > >> a test framework like the one in Vim): > >> > >> fun! Test_buffer_keyword_completion() > >> new > >> set completeopt=menuone,noselect > >> call feedkeys("ajump ju\<C-X>\<C-N>\<C-N>\<ESC>", "x") > >> call assert_equal("jump jump", getline(1)) > >> bwipe! > >> endf > >> > >> This test passes (using `vim --clean`), but if I feed this > >> key sequence instead: > >> > >> call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "x") > >> > >> the test fails: > >> > >> Expected 'jump jump' but got 'jump ju' > >> > >> Why is that? If I try the key sequences manually, both give the > >> same result. > > > > To emulate user input you must add `t` to the flags, there are some > > differences between handling input from user and input from mappings > > and without `t` you are emulating the latter. I could not list all the > > differences though. > > Adding "t" does not seem to make a difference in this case. This is a > simplified way to reproduce the difference: > > vim --clean > :set completeopt=menuone,noselect > :call feedkeys("ajump ju\<C-X>\<C-N>\<C-N>\<ESC>", "tx") > :call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "tx") > > As I said, manual typing does not show any difference (the result is > "jump jump" in both cases). Am I missing something? > I am using Vim 8.0.1450.
This happens because Vim checks for typed keys while finding matches. It then sees the CTRL-P before the first completion is found, causing it to stick to "ju". When sourcing a script with Normal mode commands, there is an extra check that prevents the completion to be aborted. I think we should do the same when using feedkeys(), as it's a very similar thing. And it's very difficult to do this in another way. However, this may break completion plugins. Or make them work better, hard to predict. I can make the change for this and await reports... -- GUARD #1: Where'd you get the coconut? ARTHUR: We found them. GUARD #1: Found them? In Mercea? The coconut's tropical! ARTHUR: What do you mean? GUARD #1: Well, this is a temperate zone. The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.