From a202921235f07f1fd5ff66e8968663e06e621888 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 5 Jun 2023 10:50:17 +0100 Subject: [PATCH] Write buffer before staging whole file We stage the whole file with `git-add` so we must ensure the file on disk reflects the buffer's contents. See #796. --- autoload/gitgutter/hunk.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 1e09ce8..e76cd9b 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -299,6 +299,9 @@ function! s:stage(hunk_diff) let choice = input('File uses clean/smudge filter. Stage entire file (y/n)? ') normal! : if choice =~ 'y' + " We are about to add the file to the index so write the buffer to + " ensure the file on disk matches it (the buffer). + write let path = gitgutter#utility#repo_path(bufnr, 1) " Add file to index. let cmd = gitgutter#utility#cd_cmd(bufnr,