From 7db6b2f79d432ee3820668b1d4625311dbe1d0ad Mon Sep 17 00:00:00 2001 From: Travis Collins Date: Thu, 26 Sep 2024 15:50:49 -0600 Subject: [PATCH] Exit copy-mode when clearing terminal screen (#233) --- plugin/vimux.vim | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index f345d30..67072a9 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -74,16 +74,8 @@ function! VimuxRunCommand(command, ...) abort let l:resetSequence = VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command - 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 s:exitCopyMode() call VimuxSendKeys(l:resetSequence) - call VimuxSendText(a:command) if l:autoreturn ==# 1 call VimuxSendKeys('Enter') @@ -178,6 +170,7 @@ endfunction function! VimuxClearTerminalScreen() abort if exists('g:VimuxRunnerIndex') && s:hasRunner(g:VimuxRunnerIndex) !=# -1 + call s:exitCopyMode() call VimuxSendKeys('C-l') endif endfunction @@ -217,6 +210,17 @@ function! VimuxTmux(arguments) abort endif endfunction +function! s:exitCopyMode() abort + try + call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) + catch + let l:versionString = s:tmuxProperty('#{version}') + if str2float(l:versionString) < 3.2 + call VimuxSendKeys('q') + endif + endtry +endfunction + function! s:tmuxSession() abort return s:tmuxProperty('#S') endfunction