From ac920417b800150a3c30b9dda9ed78d31fbf3ff4 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Fri, 22 Feb 2013 09:57:21 +0100 Subject: [PATCH] Only act when there is a file to act on. --- plugin/gitgutter.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 594c31d..896e214 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -39,6 +39,10 @@ function! s:current_file() return expand("%:p") endfunction +function! s:exists_current_file() + return strlen(s:current_file()) > 0 +endfunction + function! s:directory_of_current_file() return expand("%:p:h") endfunction @@ -189,7 +193,7 @@ endfunction " Public interface {{{ function! GitGutter() - if s:is_in_a_git_repo() && s:is_tracked_by_git() + if s:exists_current_file() && s:is_in_a_git_repo() && s:is_tracked_by_git() call s:init() let diff = s:run_diff() let hunks = s:parse_diff(diff)