diff --git a/doc/vimux.txt b/doc/vimux.txt index 1d25ca1..efc3898 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -332,12 +332,17 @@ Default: 1 *VimuxConfiguration_reset_sequence* 4.4 g:VimuxResetSequence~ -The keys sent to the runner pane before running a command. By default it sends -`q` to make sure the pane is not in scroll-mode and `C-u` to clear the line. +The keys sent to the runner pane before running a command. + +When vimux runs a tmux command, it first makes sure that the runner is not in +copy mode by running `copy-mode -q` on the runner. This sequence is then sent +to make sure that the runner is ready to receive input. + +The default sends `C-u` to clear the line. > let g:VimuxResetSequence = "" < -Default: "q C-u" +Default: "C-u" ------------------------------------------------------------------------------ *VimuxPromptString* diff --git a/plugin/vimux.vim b/plugin/vimux.vim index ac950c5..f345d30 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -9,7 +9,7 @@ let g:VimuxHeight = get(g:, 'VimuxHeight', '20%') let g:VimuxOpenExtraArgs = get(g:, 'VimuxOpenExtraArgs', '') let g:VimuxOrientation = get(g:, 'VimuxOrientation', 'v') let g:VimuxPromptString = get(g:, 'VimuxPromptString', 'Command? ') -let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'q C-u') +let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'C-u') let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '') let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') let g:VimuxRunnerQuery = get(g:, 'VimuxRunnerQuery', {}) @@ -71,9 +71,19 @@ function! VimuxRunCommand(command, ...) abort if exists('a:1') let l:autoreturn = a:1 endif - let resetSequence = VimuxOption('VimuxResetSequence') + let l:resetSequence = VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command - call VimuxSendKeys(resetSequence) + + try + call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) + catch + let l:versionString = s:tmuxProperty('#{version}') + if str2float(l:versionString) < 3.2 + let l:resetSequence = 'q '.l:resetSequence + endif + endtry + call VimuxSendKeys(l:resetSequence) + call VimuxSendText(a:command) if l:autoreturn ==# 1 call VimuxSendKeys('Enter')