On 09/02/2018 22:41, Lifepillar wrote:
> Unfortunately, I still have some problems when I test my plugin's
> mappings. I have traced back the issue to the following:
> 
>    fun! s:dup_complete()
>      " Get the text in front of the cursor
>      return getline('.')[0:col('.') - 2]
>    endf
> 
>    fun! Test_dup_completion()
>      new
>      imap <buffer> <expr> <silent> <plug>(Dup) <sid>dup_complete()
>      call feedkeys("ajump\<plug>(Dup)", "tx")
>      call assert_equal("jumpjump", getline(1))
>      bwipe!
>    endf
> 
> It seems that in s:dup_complete() getline('.') is always empty and
> col('.') is always 1. Is there anything I can do about it?
For the record, I was able to make the test pass by rewriting it as
follows:
   fun! Test_FOO_dup_completion()
     new
     imap <buffer> <expr> <silent> <plug>(Dup) <sid>dup_complete()
     call feedkeys("ajump", "tx")
     call feedkeys("a", "t!")
     call feedkeys("\<plug>(Dup)", "tx")
     call assert_equal("jumpjump", getline(1))
     bwipe!
   endf
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:
Post a Comment