How do you handle counts with a popup menu filter?

Something like this almost works:

    let s:n =  0
    fun MyFilter(winid, key)
      if a:key == '+'
        let s:n += v:count1
        call popup_settext(a:winid, printf('Value: %d', s:n))
        return 1
      endif
      return 0
    endf

    let id = popup_create('Value: 0',
          \ #{ close: 'button',
          \    border:[1,1,1,1],
          \    filter: 'MyFilter'})

I can type, say, 5+ to have the counter increased by 5.

Unfortunately, v:count1 is not cleared after that, so if I type 3+ next,
the counter is increased by 53 instead of 3. Is there a workaround?

Thanks,
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/riqqtj%24knr%241%40ciao.gmane.io.

Reply via email to