Make the 'exceeded max signs' warning less intrusive.

- Only show it once per buffer.
- Redraw before echo to avoid the hit-enter prompt.

See #259.
This commit is contained in:
Andy Stewart
2016-01-13 16:05:18 +00:00
parent f52f875fc7
commit 3a810a9afc
2 changed files with 11 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ function! gitgutter#process_buffer(bufnr, realtime)
let modified_lines = gitgutter#diff#process_hunks(gitgutter#hunk#hunks())
if len(modified_lines) > g:gitgutter_max_signs
call gitgutter#utility#warn('exceeded maximum number of signs (configured by g:gitgutter_max_signs).')
call gitgutter#utility#warn_once('exceeded maximum number of signs (configured by g:gitgutter_max_signs).', 'max_signs')
call gitgutter#sign#clear_signs()
return
endif

View File

@@ -10,6 +10,16 @@ function! gitgutter#utility#warn(message)
let v:warningmsg = a:message
endfunction
function! gitgutter#utility#warn_once(message, key)
if empty(getbufvar(s:bufnr, a:key))
call setbufvar(s:bufnr, a:key, '1')
echohl WarningMsg
redraw | echo 'vim-gitgutter: ' . a:message
echohl None
let v:warningmsg = a:message
endif
endfunction
" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't.
" This function does not and should not make any system calls.
function! gitgutter#utility#is_active()