context.vim icon indicating copy to clipboard operation
context.vim copied to clipboard

Context doesn't update when switching buffers with fzf.vim

Open thisisrandy opened this issue 2 years ago • 1 comments

As the video below demonstrates, context doesn't update when switching buffers with fzf.vim. The video also demonstrates some other things:

  1. Context updates as soon as a scroll action is taken, as expected.
  2. Context does update if we use buffer to switch. This is strange, because fzf.vim appears to also use buffer to switch when that's the correct thing to do.
  3. I put f at the top of context#update to see if it's being executed, and indeed, you'll notice that the command-line updates even though context does not.

fzf-context

Since it appears to me that context#update is exactly the function that is supposed to be updating context but is somehow not doing so even though it's being called, I'm currently stumped as to what the problem is. Help would be much appreciated.

thisisrandy avatar Jul 12 '23 23:07 thisisrandy

I had some time to dig in a little more. The problem is at line 112 of context.vim, which declines to update if mode() != n. When the call is made to context#update after fzf.vim selects a buffer, mode() == 't'. I'm not sure precisely why this is, but fzf.vim runs out of a terminal window, so I guess the mode remains t even after the selected buffer has been entered.

Line 114 separately checks that the buffer isn't a terminal, so I don't see any problem with checking that the mode isn't n and isn't t to fix this. I'll submit a PR and let you tell me there if that idea has any unforeseen consequences.

thisisrandy avatar Jul 20 '23 02:07 thisisrandy