From d20d785661f302560d522810567f489b12a2fa74 Mon Sep 17 00:00:00 2001 From: Caleb Spare Date: Thu, 11 Feb 2016 00:31:30 -0800 Subject: [PATCH] Remember fmt failure on a per-buffer basis Fixes #720 --- autoload/go/fmt.vim | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/autoload/go/fmt.vim b/autoload/go/fmt.vim index 817a76d0b5..bad4fa5c64 100644 --- a/autoload/go/fmt.vim +++ b/autoload/go/fmt.vim @@ -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 @@ -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 = [] @@ -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