From c337eef1b735906411577f488e977be69506ef08 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 24 Feb 2020 15:42:05 +0000 Subject: [PATCH] Make hunk commands noops when file not tracked by git Fixes #680. --- autoload/gitgutter/hunk.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index c51dd7a..aadf886 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -172,6 +172,8 @@ endfunction function! gitgutter#hunk#stage(...) abort + if !s:in_hunk_preview_window() && !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + if a:0 && (a:1 != 1 || a:2 != line('$')) call s:hunk_op(function('s:stage'), a:1, a:2) else @@ -181,11 +183,15 @@ function! gitgutter#hunk#stage(...) abort endfunction function! gitgutter#hunk#undo() abort + if !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + call s:hunk_op(function('s:undo')) silent! call repeat#set("\(GitGutterUndoHunk)", -1) endfunction function! gitgutter#hunk#preview() abort + if !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + call s:hunk_op(function('s:preview')) silent! call repeat#set("\(GitGutterPreviewHunk)", -1) endfunction