Skip to content

Commit aad6ace

Browse files
caojoshuaairblade
authored andcommitted
When using loclist, only add hunks for current file.
1 parent 0f98634 commit aad6ace

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

autoload/gitgutter.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ endfunction
179179
" - this runs synchronously
180180
" - it ignores unsaved changes in buffers
181181
" - it does not change to the repo root
182-
function! gitgutter#quickfix()
182+
function! gitgutter#quickfix(current_file)
183183
let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' rev-parse --show-cdup'
184184
let path_to_repo = get(systemlist(cmd), 0, '')
185185
if !empty(path_to_repo) && path_to_repo[-1:] != '/'
@@ -191,6 +191,9 @@ function! gitgutter#quickfix()
191191
\ ' diff --no-ext-diff --no-color -U0'.
192192
\ ' --src-prefix=a/'.path_to_repo.' --dst-prefix=b/'.path_to_repo.' '.
193193
\ g:gitgutter_diff_args. ' '. g:gitgutter_diff_base
194+
if a:current_file
195+
let cmd = cmd.' -- '.expand('%:p')
196+
endif
194197
let diff = systemlist(cmd)
195198
let lnum = 0
196199
for line in diff

doc/gitgutter.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ Commands for jumping between hunks:~
158158
>
159159
command! Gqf GitGutterQuickFix | copen
160160
<
161+
*gitgutter-:GitGutterQuickFixCurrentFile*
162+
:GitGutterQuickFixCurrentFile Same as :GitGutterQuickFix, but only load hunks for
163+
the file in the focused buffer. This has the same
164+
functionality as :GitGutterQuickFix when the focused
165+
buffer is empty.
161166

162167

163168
Commands for operating on a hunk:~

plugin/gitgutter.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ command! -bar GitGutterBufferDisable call gitgutter#buffer_disable()
118118
command! -bar GitGutterBufferEnable call gitgutter#buffer_enable()
119119
command! -bar GitGutterBufferToggle call gitgutter#buffer_toggle()
120120

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

123124
" }}}
124125

0 commit comments

Comments
 (0)