jamessan / vim-gnupg

This script implements transparent editing of gpg encrypted files.
http://www.vim.org/scripts/script.php?script_id=3645
728 stars 73 forks source link

Conflicts with tmux-plugins/vim-tmux-focus-events #38

Closed cpixl closed 9 years ago

cpixl commented 9 years ago

Whenever I open an .gpg file, its contents are echoed on the bottom of screen with the 'Press ENTER or type command to continue' message right after.

If I disable the vim-tmux-focus-events plugin or if I set g:GPGUsePipes=1, everything works fine.

Also, my &t_EI and &t_SI settings are being removed by vim-gnupg even without vim-tmux-focus-events. Not sure if this is somewhat related to the same issue.

jamessan commented 9 years ago

Both of these are likely items that need to be handled in vim-tmux-focus-events. That being said, I'll try to provide some information on what might be going on.

For the contents echoing at the bottom of the screen, my best guess is that it's an odd interaction with BufReadCmd. As a simple test, you could try these steps and see if you can reproduce similar behavior:

$ vim
:au BufReadCmd .vimrc :exe '0r !cat '.shellescape(expand('<afile>'), 1) | $d _ | exe 'doau BufReadPost '.fnameescape(expand('<afile>'))
:e ~/.vimrc

The t_IE/t_SI behavior is related to https://github.com/jamessan/vim-gnupg/issues/36#issuecomment-118623901. I'd suggest that the vim-tmux-focus-events folks look at the TermChanged autocmd event, since anything that sets 'term' is going to cause the behavior you're seeing. vim-gnupg just has to set 'term' for convoluted reasons.

cpixl commented 9 years ago

Hmmmm, tried the suggested steps and it worked without issues... no echoing on the bottom of screen.

Just to make things clear (maybe I didn't understand correctly, but anyway), the &t_IE and &t_SI being unset is not related to the vim-tmux-focus-events plugin, as it happens even when your plugin is the only one on my vimrc.

jamessan commented 9 years ago

Yes, the t_IE/t_SI issues are because vim-gnupg has the line let &term=&term, for the reasons described in https://github.com/jamessan/vim-gnupg/issues/36#issuecomment-118623901. However, vim-gnupg also emits the TermChanged autocmd event when this happens.

Even without vim-gnupg, if anything changed the value of 'term', then vim-tmux-focus-events would be broken because it isn't listening for TermChanged and setting up t_IE/t_SI again. That vim-gnupg has to set 'term' is a comedy of errors, but that doesn't change the fact that anyone changing 'term' is going to break the tmux plugin.

cpixl commented 9 years ago

Got it! Well, I was setting t_IE and t_SI on my vimrc manually, so I just au TermChanged * and it works fine now! Thank you!

About the echoing in the bottom of screen, the issue persists... and as you suggested the test with BufReadCmd didn't replicate the behavior. Any idea?

jamessan commented 9 years ago

Not off-hand. I'll try to find some time to look into that soon.

bruno- commented 9 years ago

Hi, I started using this plugin - great stuff!

I also get Press ENTER or type command to continue message at the bottom when opening encrypted file. I also use vim-tmux-focus-events plugin.

I investigated the issue and it seems it starts happening with this commit bd3ebdf. I further confirmed this by commenting out this let &term = &term around line 1295 in plugin/gnupg.vim. When this is done, the issue does not happen anymore.

Another way to "fix" the issue to work with vim-tmux-focus-events is by leaving let &term = &term and just having something like this (2 lines below added, they replicate what vim-tmux-focus-events does):

let &term = &term
exec "set <F24>=\<Esc>[O"
exec "set <F25>=\<Esc>[I"
jamessan commented 9 years ago

@bruno- Or for vim-tmux-focus-events to set any of their term-related settings when the TermChanged autocmd triggers, as I suggested in https://github.com/jamessan/vim-gnupg/issues/38#issuecomment-120679014.

bruno- commented 9 years ago

Thank you very much sir, that's the right way to handle this! It's now fixed https://github.com/tmux-plugins/vim-tmux-focus-events/commit/bb36f0cb9c9ac0524613ac36292250ab936e718f, case closed.

jamessan commented 9 years ago

Thanks! Now I just need to find time to try and fix the vim + gnupg interaction that required this workaround. :)