I am working on a plugin and as part of that plugin I am trying to update the statusline with setlocal statusline=%!GetMPCStatusline().

But this causes vimrun.exe to open and close very fast. This happens only when I focus in the window where the statusline is set and not the others.

I am attaching this screen grab of Vimrun.exe opening and closing. It just keeps happening in the background but it doesn't open anything.

enter image description here

So, Why is this happening and what can I do to make this stop?

PS: I am using GVim 7.4 on Windows.

Edit: I just tried this in the terminal Vim (powershell) and Vim in cygwin. There even though I am not getting this, something weird is happening there too. The cursor moves really really slow as if something is obstructing it.

Edit 2: This is the function its calling. It gets the output from the mpc status, mpc playlist command and parses them. When I run this function manually I can see the vimrun on the taskbar once and it disappears after that.

function! GetMPCStatusline()
    let cmd = "mpc status"
    let result = split(system(cmd), '\n')
    let status = len(result) == 3 ? result[2] : result[0]

    let [s:count, s:settings] =
                \ [len(split(system('mpc playlist'), '\n')),
                \ split(status, '   ')]

    let s:statusline = " "
                \ . s:settings[1] . " --- "
                \ . s:settings[2] . " ---%="
                \ . s:count . " songs "
    return s:statusline

Edit 3: This doesn't happen when I have another function for the statusline. So, the only thing common in all the above tests is the statusline function above and hence I guess that has to be the reason why this is happening. Any ideas on why that is the case?

  • 1
    Sounds like an infinite while loop or nested recursion, but it's hard to say. I would start by making sure that your function GetMPCStatusline() doesn't have any problems.
    – Tumbler41
    Jul 18 '16 at 20:19
  • 2
    Your function is called each time the screen is repainted for one reason or another (cursor move, edit, switch to another buffer, whatever). It takes time so you get that annoying delay and it happens very often so you get that flicker. You need to "debounce" it.
    – romainl
    Jul 18 '16 at 21:00
  • @romainl What does 'debounce' mean? Jul 19 '16 at 4:02
  • @Tumbler41 I've added the statusline function its calling. I don't see any problem with it but when I do run it manually I get that vimrun just once. So, since this function is getting called multiple times, I am guessing that's why vimrun keeps coming again and again. Jul 19 '16 at 4:16
  • 1
    "debounce" means that you must make sure the function is not called every couple of millisecond. Generally you do that by comparing the current timestamp with the timestamp of the last run. In other words, your function itself is not at fault, it's how you call it.
    – romainl
    Jul 19 '16 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.