Skip to content

Commit

Permalink
Prevent automatic scroll on switching splits (#32)
Browse files Browse the repository at this point in the history
* Moved insert switching into sendlines

* Bumped readme version number

* Made the code more readable
  • Loading branch information
williamjameshandley committed Dec 30, 2020
1 parent 319609a commit d734943
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Vimteractive
============
:vimteractive: send commands from text files to interactive programs via vim
:Author: Will Handley
:Version: 2.3.1
:Version: 2.4.0
:Homepage: https://github.com/williamjameshandley/vimteractive
:Documentation: ``:help vimteractive``

Expand Down
10 changes: 8 additions & 2 deletions autoload/vimteractive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ function! vimteractive#sendlines(lines)

let l:term_type = getbufvar(b:vimteractive_connected_term, "vimteractive_term_type")

" Switch to insert mode if the terminal is currently in normal mode
let l:term_status = term_getstatus(b:vimteractive_connected_term)
if stridx(l:term_status,"normal") != -1
execute ":b " . b:vimteractive_connected_term
execute "silent! normal! i"
bprevious
endif

if get(g:vimteractive_bracketed_paste, l:term_type, g:vimteractive_bracketed_paste_default)
call term_sendkeys(b:vimteractive_connected_term,"[200~" . a:lines . "[201~\n")
else
Expand Down Expand Up @@ -144,8 +152,6 @@ function! vimteractive#term_start(term_type)
if g:vimteractive_switch_mode
" Switch to terminal-normal mode when entering buffer
autocmd BufEnter <buffer> call feedkeys("\<C-W>N")
" Switch to insert mode when leaving buffer
autocmd BufLeave <buffer> execute "silent! normal! i"
endif
" Make :quit really do the right thing
cabbrev <buffer> q bdelete! "
Expand Down

0 comments on commit d734943

Please sign in to comment.