From 49eaa8d6601dcdf8281b6c80ae43bfc87888e3ea Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 26 Aug 2024 17:39:39 -0700 Subject: [PATCH 1/3] Use `copy-mode -q` to leave copy mode --- doc/vimux.txt | 11 ++++++++--- plugin/vimux.vim | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) 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..a86790f 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', {}) @@ -73,6 +73,7 @@ function! VimuxRunCommand(command, ...) abort endif let resetSequence = VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command + call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) call VimuxSendKeys(resetSequence) call VimuxSendText(a:command) if l:autoreturn ==# 1 From b002925b506fa35439a8cfe335d6b4433f622150 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 1 Sep 2024 22:47:43 -0700 Subject: [PATCH 2/3] Prefix 'q ' to reset sequence for older versions --- plugin/vimux.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a86790f..3d26239 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -71,10 +71,20 @@ 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 VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) - 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 + else + endif + endtry + call VimuxSendKeys(l:resetSequence) + call VimuxSendText(a:command) if l:autoreturn ==# 1 call VimuxSendKeys('Enter') From 20ec061025711c87b786c5ad50c1a0b4c7a260f2 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Wed, 18 Sep 2024 18:54:47 -0700 Subject: [PATCH 3/3] Remove unnecessary 'else' statement --- plugin/vimux.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 3d26239..f345d30 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -80,7 +80,6 @@ function! VimuxRunCommand(command, ...) abort let l:versionString = s:tmuxProperty('#{version}') if str2float(l:versionString) < 3.2 let l:resetSequence = 'q '.l:resetSequence - else endif endtry call VimuxSendKeys(l:resetSequence)