vimux icon indicating copy to clipboard operation
vimux copied to clipboard

Prevent errors when runner is closed by something other than vimux

Open mvanderkamp opened this issue 11 months ago • 1 comments

As seen in #236, if the runner was already manually closed when we call VimuxCloseRunner we get the following error:

Error detected while processing function VimuxCloseRunner[2]..VimuxTmux[8]..function VimuxCloseRunner[2]..VimuxTmux:
line    8:
E605: Exception not caught: Tmux command failed with message:can't find pane: %19^@
Error detected while processing function VimuxCloseRunner:
line    2:
E171: Missing :endif

This is an annoyance for people who use VimuxCloseOnExit. The error could spread to other commands as well, since the error prevents vimux from unsetting VimuxRunnerIndex, leading other commands to believe the runner is still available.

The error can occur in other contexts too, as seen in #229.

We generally only check if the VimuxRunnerIndex variable is defined before attempting to interact with the runner. This variable is only unset if vimux closes the runner, so any time anything else loses the runner we will get errors.

We have some options:

  1. Always check for the existence of the runner before interacting with it.
  2. Add try-catch blocks around each command to check for these errors.

I think for now I'll just enhance the checks we already have to make sure that the runner actually exists, rather than just checking for the index variable's existence.

mvanderkamp avatar Dec 07 '24 21:12 mvanderkamp