0

This is a follow up to a previous question.

Thanks to that, I could come up with this augroup:

augroup Foo
  autocmd!
  autocmd TextChangedI,TextChangedP * call <SID>foo()
  fun s:foo()
    let msg = execute('%s/.//gn')->split('\n')[0]
    echo msg
    let a = getpos("'`")
    call cursor(a[1], a[2])
    call popup_atcursor(msg->split('\n')[0], #{})
  endf
augroup END

which makes the current number of characters in the file to be shown both in the command line, via :echo, and in a popup, via popup_atcursor.

The weird thing about the latter is that it doesn't get updated if another popup, for me the one shown by YCM, is showing. Here's a live demo:

asciicast

You can see that

  • when I enter insert mode and write the first character, "my" popup is shown, with a given number
  • upon entering the second character, the number in my popup is updated and YCM's popup pops up (because I have let g:ycm_min_num_of_chars_for_completion = 2 in my vimrc),
  • upon entering further characters such that the YCM popup is not dismissed, my popup doesn't update anymore (whereas the text echod in the command line does),
  • as soon as I type one character that causes YCM's popup to be dismissed, then my popup is updated.

The fact that echo is indeed printing text even while YCM's popup is up is a proof that the s:foo function is indeed running for every single character I type.

However, it looks like the call to call popup_atcursor(msg->split('\n')[0], #{}) is not updating the popup.

Why is this the case?


Adding call popup_clear() right before call popup_atcursor(msg->split('\n')[0], #{}) seems to do the trick, but I suspect it's not really the right thing to do?

Enlico
  • 2,194
  • 15
  • 31

0 Answers0