christoomey / vim-tmux-runner

Vim and tmux, sittin' in a tree...
MIT License
291 stars 37 forks source link

Tmux gets killed when vim pane is zoomed #68

Closed blelump closed 7 years ago

blelump commented 7 years ago

Hi @christoomey ,

first of all, huge thanks for your contributions into this plugin. I've encountered an issue while working with attached pane. Let me clarify it with these steps to reproduce:

  1. Having one pane in Tmux window, open vim;
  2. Run :VtrSendCommand! ls to attach pane and get ls output (just for the sake of the example);
  3. Run :VtrSendCommandToRunner echo "ok" – all is still fine and both, vim and shell panes are visible;
  4. Run ^prefix + Z from within Tmux so the vim pane is now zoomed/maximized.
  5. Run :VtrSendCommandToRunner echo "ok" again – you get [lost server] and the Tmux server is killed.
# env:
$ tmux -V
tmux 2.4

A workaround might be to use VtrKillRunner each time vim pane is zoomed so any further 'shell pane' invocations will attach to a new pane.

Edit

I've ended up with the function given below. It is used with vim-test plugin altogether. If you have a better idea of solving it, feel free to share :smile: .

function! s:ResizePane()
  call system("tmux list-panes -F '#F' | grep -q Z")
  if !(v:shell_error)
    call system('tmux resize-pane -Z')
  endif
endfunction
christoomey commented 7 years ago

@blelump Sorry to hear about the trouble. It sounds as though this is a tmux issue, not specific to this plugin. Specifically, running tmux send-keys ... while in a zoomed pane should maybe display a warning (or in my case it targets the zoomed pane, rather than the pane specified by -t <pane-index>), but certainly not kill the server.

That said, we should probably handle this case a bit better regardless. Your workaround is very novel. I wonder if instead if the plugin should detect and unzoom if you try to send a command again.

I'm not sure I'll have time to work on this anytime soon, but if you're interested, feel free to put something together in a PR and I'd be happy to review.

blelump commented 7 years ago

@christoomey ,

thanks for answering !

Let me clarify the intention of that code above – perhaps I am missing something. I am using VTR along with vim-test plugin to run tests. The problem is that once you run a test and new Tmux pane appears, you're not able to easily hide (although closing is easy) the newly created pane. I think I don't want to close it permanently, because if the test has failed, I'd like to examine the stacktrace a few times, i.e. using VtrFocusRunner feature, then go back to Vim, hide test pane and do some editing, then switch again to the test pane etc. I just would like to not kill the pane, but rather hide it so I'm able to go back and look into it. Is my way of thinking correct?

christoomey commented 7 years ago

Hey @blelump, thanks for clarifying. When I first started the plugin I had a :VtrDetachRunner command, but it's a bit flaky unfortunately. This is certainly something we could support, but would take some effort to do so.

While I hate to send you away, I think the use case your describing might actually be a perfect match for tpope's vim-dispatch which will use tmux if available, auto-hide on test success, and keep the pane open on failures. I personally like to keep the pane open all the time and more explicitly manage the tmux running, thus the existence of this plugin, but based on what you've described, I think dispatch might be a perfect fit for you.

Sorry I couldn't give a better answer, but hopefully that clarifies things.

I'm going to close this now as I believe the crashing of tmux is unrelated to this plugin, and I think any work towards the workflow you're describing is better captured in https://github.com/christoomey/vim-tmux-runner/issues/66, but please feel free to comment or reopen if you think I've missed something.

blelump commented 7 years ago

@christoomey ,

sure, thanks for clarification !