Move window state recall outside TryFormatter

This commit is contained in:
Chiel92 2015-06-12 14:29:33 +02:00
parent ba12dfc1b7
commit f7e872f15a

View File

@ -118,9 +118,6 @@ function! s:TryFormatter()
return 1 return 1
endif endif
" Save window state
let winview=winsaveview()
python << EOF python << EOF
import vim, subprocess, os import vim, subprocess, os
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
@ -145,15 +142,13 @@ else:
vim.current.buffer[:] = stdoutdata.split('\n') vim.current.buffer[:] = stdoutdata.split('\n')
EOF EOF
" Recall window state
call winrestview(winview)
return 1 return 1
endfunction endfunction
" Create a command for formatting the entire buffer " Create a command for formatting the entire buffer
command! -nargs=? -range=% -complete=filetype Autoformat <line1>,<line2>call s:TryAllFormatters(<f-args>) " Save and recall window state to prevent vim from jumping to line 1
command! -nargs=? -range=% -complete=filetype Autoformat let winview=winsaveview()|<line1>,<line2>call s:TryAllFormatters(<f-args>)|call winrestview(winview)
" Functions for iterating through list of available formatters " Functions for iterating through list of available formatters