Skip to content

Commit

Permalink
Exit copy-mode when clearing terminal screen (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
tradiff authored Sep 26, 2024
1 parent 64df7ce commit 7db6b2f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions plugin/vimux.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7db6b2f

Please sign in to comment.