From be87b74b55a5b4b0cb397a0312f3c7fa755a79af Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jul 2018 00:23:30 +1200 Subject: Don't require blocks to have a parent file Per a bug report from Maksim Odnoletkov; this seems to make the mappings work for the diffs generated with `git add --patch`. --- autoload/diff/prune.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/diff/prune.vim b/autoload/diff/prune.vim index cfbce97..a562d71 100644 --- a/autoload/diff/prune.vim +++ b/autoload/diff/prune.vim @@ -16,6 +16,8 @@ function! diff#prune#Prune(type) abort " Now we need to look for any blocks or files to remove if they have no " changes in them anymore + let l:file_changes = 0 + let l:block_changes = 0 let l:deletions = {} for l:li in range(1, line('$') + 1) @@ -34,7 +36,6 @@ function! diff#prune#Prune(type) abort let l:block = stridx(l:line, '@@') == 0 && !l:eof let l:change = (stridx(l:line, '+') == 0 || stridx(l:line, '-') == 0) \ && !l:eof - \ && exists('l:file_start') \ && exists('l:block_start') " End of old file: flag previous file lines for deletion if no changes, -- cgit v1.2.3 From dceac6c2bc7dbf3fea172c4f8c29159b117fe4dd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jul 2018 00:26:25 +1200 Subject: Use .= for b:undo_ftplugin appending --- after/ftplugin/diff/prune.vim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/after/ftplugin/diff/prune.vim b/after/ftplugin/diff/prune.vim index 185d04f..53e05cb 100644 --- a/after/ftplugin/diff/prune.vim +++ b/after/ftplugin/diff/prune.vim @@ -17,19 +17,16 @@ endif " Flag as loaded let b:did_ftplugin_diff_prune = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_diff_prune' +let b:undo_ftplugin .= '|unlet b:did_ftplugin_diff_prune' " Define normal mode mapping target nnoremap \ (DiffPrune) \ :set operatorfunc=diff#prune#Pruneg@ -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap (DiffPrune)' +let b:undo_ftplugin .= '|nunmap (DiffPrune)' " Define visual mode mapping target vnoremap \ (DiffPrune) \ :call diff#prune#Prune(visualmode()) -let b:undo_ftplugin = b:undo_ftplugin - \ . '|vunmap (DiffPrune)' +let b:undo_ftplugin .= '|vunmap (DiffPrune)' -- cgit v1.2.3 From 40cf387734ab919ea90a246bb8101aa4b6501bff Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jul 2018 00:36:41 +1200 Subject: Mention `git-add --patch` in docs --- README.md | 3 ++- doc/diff_prune.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ef1769..4f8511b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ If the changes result in a diff block or file block having no changes left, it is also removed. This can be handy for using with the `-e` or `--edit` option to `git-add`, -which allows you to edit a diff before applying changes to the staging area. +which allows you to edit a diff before applying changes to the staging area. It +also seems to work for the `-p` or `--patch` option. License ------- diff --git a/doc/diff_prune.txt b/doc/diff_prune.txt index f708d73..5dbcc7d 100644 --- a/doc/diff_prune.txt +++ b/doc/diff_prune.txt @@ -11,7 +11,8 @@ If the changes result in a diff block or file block having no changes left, it is also removed. This can be handy for using with the `-e` or `--edit` option to `git-add`, -which allows you to edit a diff before applying changes to the staging area. +which allows you to edit a diff before applying changes to the staging area. It +also seems to work for the `-p` or `--patch` option. REQUIREMENTS *diff_prune-requirements* -- cgit v1.2.3 From 09b19a3c17d9fb157016b30659d61d74850e5389 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jul 2018 00:38:03 +1200 Subject: Bump documentation date --- doc/diff_prune.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/diff_prune.txt b/doc/diff_prune.txt index 5dbcc7d..d1be82b 100644 --- a/doc/diff_prune.txt +++ b/doc/diff_prune.txt @@ -1,4 +1,4 @@ -*diff_prune.txt* For Vim version 7.0 Last change: 2018 June 29 +*diff_prune.txt* For Vim version 7.0 Last change: 2018 July 14 DESCRIPTION *diff_prune* -- cgit v1.2.3 From 2f724101848ef20fa719e9f136b061381ea6ba2f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 14 Jul 2018 00:38:32 +1200 Subject: Bump VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3eefcb9..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 -- cgit v1.2.3