Skip to content

Commit

Permalink
Merge pull request #727 from mattn/fallback-mkview
Browse files Browse the repository at this point in the history
fallback for mkview
  • Loading branch information
fatih committed Feb 17, 2016
2 parents ff56a31 + ba96e1f commit 065d714
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ endif
" improvements, patches are welcome :)
function! go#fmt#Format(withGoimport)
" save cursor position, folds and many other things
mkview!
let l:curw = {}
try
mkview!
catch
let l:curw=winsaveview()
endtry

" Write current unsaved buffer to a temp file
let l:tmpname = tempname()
Expand Down Expand Up @@ -159,7 +164,11 @@ function! go#fmt#Format(withGoimport)
endif

" restore our cursor/windows positions, folds, etc..
silent! loadview
if empty(l:curw)
silent! loadview
else
call winrestview(l:curw)
endif
endfunction


Expand Down

0 comments on commit 065d714

Please sign in to comment.