Skip to content

Commit

Permalink
When using loclist, only add hunks for current file.
Browse files Browse the repository at this point in the history
  • Loading branch information
caojoshua authored and airblade committed Jul 12, 2021
1 parent 0f98634 commit aad6ace
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion autoload/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ endfunction
" - this runs synchronously
" - it ignores unsaved changes in buffers
" - it does not change to the repo root
function! gitgutter#quickfix()
function! gitgutter#quickfix(current_file)
let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' rev-parse --show-cdup'
let path_to_repo = get(systemlist(cmd), 0, '')
if !empty(path_to_repo) && path_to_repo[-1:] != '/'
Expand All @@ -191,6 +191,9 @@ function! gitgutter#quickfix()
\ ' diff --no-ext-diff --no-color -U0'.
\ ' --src-prefix=a/'.path_to_repo.' --dst-prefix=b/'.path_to_repo.' '.
\ g:gitgutter_diff_args. ' '. g:gitgutter_diff_base
if a:current_file
let cmd = cmd.' -- '.expand('%:p')
endif
let diff = systemlist(cmd)
let lnum = 0
for line in diff
Expand Down
5 changes: 5 additions & 0 deletions doc/gitgutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ Commands for jumping between hunks:~
>
command! Gqf GitGutterQuickFix | copen
<
*gitgutter-:GitGutterQuickFixCurrentFile*
:GitGutterQuickFixCurrentFile Same as :GitGutterQuickFix, but only load hunks for
the file in the focused buffer. This has the same
functionality as :GitGutterQuickFix when the focused
buffer is empty.


Commands for operating on a hunk:~
Expand Down
3 changes: 2 additions & 1 deletion plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ command! -bar GitGutterBufferDisable call gitgutter#buffer_disable()
command! -bar GitGutterBufferEnable call gitgutter#buffer_enable()
command! -bar GitGutterBufferToggle call gitgutter#buffer_toggle()

command! -bar GitGutterQuickFix call gitgutter#quickfix()
command! -bar GitGutterQuickFix call gitgutter#quickfix(v:false)
command! -bar GitGutterQuickFixCurrentFile call gitgutter#quickfix(v:true)

" }}}

Expand Down

0 comments on commit aad6ace

Please sign in to comment.