Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure fmt list gets closed when title cannot be checked #1474

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,22 @@ function! go#fmt#update_file(source, target)
let &fileformat = old_fileformat
let &syntax = &syntax

let l:listtype = go#list#Type("GoFmt")

" the title information was introduced with 7.4-2200
" https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
if !has('patch-7.4-2200')
return
endif

" clean up previous list
let l:listtype = go#list#Type("GoFmt")
if l:listtype == "quickfix"
let l:list_title = getqflist({'title': 1})
if has('patch-7.4-2200')
" clean up previous list
if l:listtype == "quickfix"
let l:list_title = getqflist({'title': 1})
else
let l:list_title = getloclist(0, {'title': 1})
endif
else
let l:list_title = getloclist(0, {'title': 1})
" can't check the title, so assume that the list was for go fmt.
let l:list_title = {'title': 'Format'}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work if you you do not have patch-7.4-2200, as l:listtype is unset, and is referenced on lines 146 / 147 below.

Add: let l:listtype = "locationlist" here to resolve the issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jthurman42. It should be resolved now.

endif

if has_key(l:list_title, "title") && l:list_title['title'] == "Format"
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
Expand Down