Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit copy-mode when clearing terminal screen #233

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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