Skip to content

Commit 83ace20

Browse files
committed
Suppress signs when there are more than 500.
1 parent fed2dba commit 83ace20

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.mkd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ Note that if you have line highlighting on and signs off, you will have an empty
8080

8181
If you switch off both line highlighting and signs, you won't see the sign column. That is unless you have set `let g:gitgutter_sign_column_always = 1` so it's always there.
8282

83+
To keep your Vim snappy, vim-gitgutter will suppress itself when a file has more than 500 changes. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with:
84+
85+
```viml
86+
let g:gitgutter_max_signs = 500 " default value
87+
```
8388

8489
#### Hunks
8590

autoload/gitgutter.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ function! gitgutter#process_buffer(file, realtime)
2323
call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(diff))
2424
let modified_lines = gitgutter#diff#process_hunks(gitgutter#hunk#hunks())
2525

26+
if len(modified_lines) > g:gitgutter_max_signs
27+
call gitgutter#utility#warn('exceeded maximum number of signs (configured by g:gitgutter_max_signs).')
28+
call gitgutter#sign#clear_signs(a:file)
29+
return
30+
endif
31+
2632
if g:gitgutter_signs || g:gitgutter_highlight_lines
2733
call gitgutter#sign#update_signs(a:file, modified_lines)
2834
endif

autoload/gitgutter/utility.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ let s:file = ''
22
let s:using_xolox_shell = -1
33
let s:exit_code = 0
44

5+
function! gitgutter#utility#warn(message)
6+
echohl WarningMsg
7+
echomsg 'vim-gitgutter: ' . a:message
8+
echohl None
9+
let b:warningmsg = a:message
10+
endfunction
511

612
function! gitgutter#utility#is_active()
713
return g:gitgutter_enabled && gitgutter#utility#exists_file()

plugin/gitgutter.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function! s:set(var, default)
2828
endfunction
2929

3030
call s:set('g:gitgutter_enabled', 1)
31+
call s:set('g:gitgutter_max_signs', 500)
3132
call s:set('g:gitgutter_signs', 1)
3233
call s:set('g:gitgutter_highlight_lines', 0)
3334
call s:set('g:gitgutter_sign_column_always', 0)

0 commit comments

Comments
 (0)