Skip to content

Commit

Permalink
Merge pull request #721 from cespare/fix-720
Browse files Browse the repository at this point in the history
Remember fmt failure on a per-buffer basis
  • Loading branch information
fatih committed Feb 11, 2016
2 parents ff1e5f3 + d20d785 commit e346153
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ if !exists("g:go_fmt_experimental")
let g:go_fmt_experimental = 0
endif

let s:got_fmt_error = 0

" we have those problems :
" http://stackoverflow.com/questions/12741977/prevent-vim-from-updating-its-undo-tree
" http://stackoverflow.com/questions/18532692/golang-formatter-and-vim-how-to-destroy-history-record?rq=1
Expand Down Expand Up @@ -120,13 +118,13 @@ function! go#fmt#Format(withGoimport)
let &fileformat = old_fileformat
let &syntax = &syntax

" clean up previous location list, but only if it's due fmt
if s:got_fmt_error
let s:got_fmt_error = 0
" clean up previous location list, but only if it's due to fmt
if exists('b:got_fmt_error') && b:got_fmt_error
let b:got_fmt_error = 0
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
endif
elseif g:go_fmt_fail_silently == 0
elseif g:go_fmt_fail_silently == 0
let splitted = split(out, '\n')
"otherwise get the errors and put them to location list
let errors = []
Expand All @@ -147,7 +145,7 @@ function! go#fmt#Format(withGoimport)
echohl Error | echomsg "Gofmt returned error" | echohl None
endif

let s:got_fmt_error = 1
let b:got_fmt_error = 1
call go#list#Window(l:listtype, len(errors))

" We didn't use the temp file, so clean up
Expand Down

0 comments on commit e346153

Please sign in to comment.