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

Discard quickfix errors when quickfix doesn't locate a file to jump to #547

Merged
merged 1 commit into from
Oct 19, 2015
Merged
Show file tree
Hide file tree
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
27 changes: 24 additions & 3 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,33 @@ function! go#cmd#Run(bang, ...)
exe 'make!'
endif

cwindow
let errors = getqflist()
" Remove any nonvalid filename from the qflist to avoid opening an empty
" buffer. See https://github.com/fatih/vim-go/issues/287 for details.
let qflist = getqflist()
Copy link
Owner

Choose a reason for hiding this comment

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

Can you put a document above this line and explain why we do the iterating. Something like: Do not add non valid filenames to avoid opening an empty buffer. Checkout https://github.com/fatih/vim-go/issues/287 for the problem

let errors = []
let is_readable = {}
Copy link
Owner

Choose a reason for hiding this comment

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

Add a newline please


for item in qflist
let filename = bufname(item.bufnr)
if !has_key(is_readable, filename)
let is_readable[filename] = filereadable(filename)
endif
if is_readable[filename]
call add(errors, item)
endif
endfor
Copy link
Owner

Choose a reason for hiding this comment

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

Add newline after endfor please


for k in keys(filter(is_readable, '!v:val'))
echo "vim-go: " | echohl Identifier | echon "[run] Dropped " | echohl Constant | echon '"' . k . '"'
echohl Identifier | echon " from QuickFix list (nonvalid filename)" | echohl None
endfor
Copy link
Owner

Choose a reason for hiding this comment

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

Add newline after endfor please


call setqflist(errors)
if !empty(errors) && !a:bang
cc 1 "jump to first error if there is any
endif

cwindow

let $GOPATH = old_gopath
let &makeprg = default_makeprg
endfunction
Expand Down
17 changes: 9 additions & 8 deletions compiler/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ else
CompilerSet makeprg=go\ build
endif

CompilerSet errorformat=
\%-G#\ %.%#,
\%-G%.%#panic:\ %m,
\%Ecan\'t\ load\ package:\ %m,
\%A%f:%l:%c:\ %m,
\%A%f:%l:\ %m,
\%C%*\\s%m,
\%-G%.%#
" Define the patterns that will be recognized by QuickFix when parsing the output of GoRun.
" More information at http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat
CompilerSet errorformat =%-G#\ %.%# " Ignore lines beginning with '#' ('# command-line-arguments' line sometimes appears?)
CompilerSet errorformat+=%-G%.%#panic:\ %m " Ignore lines containing 'panic: message'
CompilerSet errorformat+=%Ecan\'t\ load\ package:\ %m " Start of multiline error string is 'can\'t load package'
CompilerSet errorformat+=%A%f:%l:%c:\ %m " Start of multiline unspecified string is 'filename:linenumber:columnnumber:'
CompilerSet errorformat+=%A%f:%l:\ %m " Start of multiline unspecified string is 'filename:linenumber:'
CompilerSet errorformat+=%C%*\\s%m " Continuation of multiline error message is indented
CompilerSet errorformat+=%-G%.%# " All lines not matching any of the above patterns are ignored
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for adding the comments, much appreciated 👍 I'm usually spending 10/20 minutes in errorformat before jumping and fixing stuff here :)


let &cpo = s:save_cpo
unlet s:save_cpo
Expand Down