-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
let errors = [] | ||
let is_readable = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline after |
||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline after |
||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
|
There was a problem hiding this comment.
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