From 572c8510123cbde02e8a1dafcd376c98e1e13f43 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 27 Aug 2023 15:31:16 -0400 Subject: [PATCH] Never jump to invalid entry after quickfix command In particular, if the first :Ggrep result is a binary file, skip over it. I'm also leaning strongly towards not filling in the filename field at all for binary files, but I'll address that separately. --- autoload/fugitive.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 6e5095f..b4fbc92 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1576,11 +1576,15 @@ function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) ab call s:QuickfixSet(a:nr, buffer, 'a') exe s:DoAutocmd('QuickFixCmdPost ' . event) - if a:first && len(s:QuickfixGet(a:nr)) - return (a:nr < 0 ? 'cfirst' : 'lfirst') - else - return 'exe' + if a:first + let list = s:QuickfixGet(a:nr) + for index in range(len(list)) + if list[index].valid + return (index+1) . (a:nr < 0 ? 'cfirst' : 'lfirst') + endif + endfor endif + return 'exe' endfunction function! fugitive#Cwindow() abort