From 3a810a9afcccdb78fbd108fbb47fe0df1109d521 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 13 Jan 2016 16:05:18 +0000 Subject: [PATCH] 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. --- autoload/gitgutter.vim | 2 +- autoload/gitgutter/utility.vim | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/gitgutter.vim b/autoload/gitgutter.vim index 3693356..3265488 100644 --- a/autoload/gitgutter.vim +++ b/autoload/gitgutter.vim @@ -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 diff --git a/autoload/gitgutter/utility.vim b/autoload/gitgutter/utility.vim index aabe99c..e1b2fce 100644 --- a/autoload/gitgutter/utility.vim +++ b/autoload/gitgutter/utility.vim @@ -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()