Previously the VtrSendLinesToRunner command was implemented by joining
the lines together with `\r` newline characters and then sending them
via a single batch `tmux send-keys` call. This caused some REPLs (pry
most notably) to display all the lines at once, and occasionally
mis-handle the sent text.
With this change, each line is now sent via a distinct `tmux send-keys`
call, better approximating a user interacting with the REPL.
Occasionally it can be useful to be able to interact with more than one
REPL at a time. VTR doesn't have official support for this behavior, but
we can combine the `VtrAttachToPane` command and the
`VtrSendLinesToRunner` command to provide rough support for this.
This change updates the `VtrAttachToPane` configuration to support this
chaining.
*Note* this mechanism will only allow for sending single lines.
``` vim
nmap <leader>v1 :VtrAttachToPane 1 \| VtrSendLinesToRunner<cr>
nmap <leader>v2 :VtrAttachToPane 2 \| VtrSendLinesToRunner<cr>
```
This introduced an implicit dependency on zero-based pane indexing.
This code now checks that the desired pane is one of the current pane
indexes.
Closes#42 - Off by one error in runner_pane with base-index 1 in tmux
Add bang version of SendLinesToRunner and SendCommand which will ensure
a runner is present and open one if needed. Also add optional second
argument to VtrSendCommand function to ensure runner pane
Closes#27 - Add EnsurePaneAndRun
Prior to this change, VTR could get confused and focus the wrong pane
after reattaching the runner pane.
Closes#38 - Detaching the runner pane does not reset the vim_pane
This protects all commands that expect a runner pane from runner
against an invalid pane, including the Vim pane. Since the user can
modified the tmux layout and open and close panes outside the context
of VTR, it's neccesary to check this before any command that requires
the runner pane.
Closes#28 - Protect against running command against invalid panes
The functionality was largely duplicated across the commands, and with
regard to naming, `FocusRunnerPane` better maps to how I use it.
Closes#35 - Unify Focus & Zoom runner pane functions
Previous behavior was to implicitly open a runner pane if none
attached. I regularly ran into this in unwanted circumstances. With the
recent updated to make AttachToPane smarter, an error plus quick
manual attach is nearly as quick as the implicit form, but is much
better overall.
Closes#36 - Explicitly error when running without a pane attached
ReorientRunner needs to know the current orientation in order to be
able to toggle it. With this change, we capture the current major
orientation (outermost split orientation) and assume it to be
representative. Imperfect, but I believe it to be a very good
approximation.
Closes#32 - Error: Reorient Runner fails when run after manual attach
- Automatically attach if only 2 panes
- Ensure pane with index exists before attaching
The runner_pane must not be the Vim pane, so if there are only two
panes, then we can be certain that the desired pane is the other, and
automatically attach
Closes#20 - Make AttachToPane command smarter
If the user has swapped the pane layout, it is possible that VTR could
attempt to kill the Vim pane. This introduces a sanity check that
prevents killing the active / Vim pane.
Closes#7 - Protect against killing Vim pane