Skip to content

Commit 1c1980f

Browse files
committed
ensure fmt list gets closed when title cannot be checked
1 parent dcd3e3b commit 1c1980f

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

autoload/go/fmt.vim

+12-9
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,22 @@ function! go#fmt#update_file(source, target)
127127
let &fileformat = old_fileformat
128128
let &syntax = &syntax
129129

130+
let l:listtype = go#list#Type("GoFmt")
131+
130132
" the title information was introduced with 7.4-2200
131133
" https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
132-
if !has('patch-7.4-2200')
133-
return
134-
endif
135-
136-
" clean up previous list
137-
let l:listtype = go#list#Type("GoFmt")
138-
if l:listtype == "quickfix"
139-
let l:list_title = getqflist({'title': 1})
134+
if has('patch-7.4-2200')
135+
" clean up previous list
136+
if l:listtype == "quickfix"
137+
let l:list_title = getqflist({'title': 1})
138+
else
139+
let l:list_title = getloclist(0, {'title': 1})
140+
endif
140141
else
141-
let l:list_title = getloclist(0, {'title': 1})
142+
" can't check the title, so assume that the list was for go fmt.
143+
let l:list_title = {'title': 'Format'}
142144
endif
145+
143146
if has_key(l:list_title, "title") && l:list_title['title'] == "Format"
144147
call go#list#Clean(l:listtype)
145148
call go#list#Window(l:listtype)

0 commit comments

Comments
 (0)