From 6e396401a67df90f9099d952ebdb40307d31edaa Mon Sep 17 00:00:00 2001 From: aweaver Date: Tue, 27 Sep 2022 12:26:26 +0200 Subject: [PATCH 1/2] Fix unwanted update during rebase Using an execute cmd checking if a rebase is in progress to deny the update. Fix #10 --- plugin/stdheader.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugin/stdheader.vim b/plugin/stdheader.vim index da78555..7a09d87 100644 --- a/plugin/stdheader.vim +++ b/plugin/stdheader.vim @@ -126,6 +126,9 @@ function! s:insert() endfunction function! s:update() + if s:rebasing() + return 1 + endif call s:filetype() if getline(9) =~ s:start . repeat(' ', s:margin - strlen(s:start)) . "Updated: " if &mod @@ -143,6 +146,13 @@ function! s:stdheader() endif endfunction +function! s:rebasing() + if system("ls `git rev-parse --git-dir 2>/dev/null` | grep rebase | wc -l") + return 1 + endif + return 0 +endfunction + " Bind command and shortcut command! Stdheader call s:stdheader () map :Stdheader From d86ed02fbc9b3440fb6fe3fdd5746f768ff98a53 Mon Sep 17 00:00:00 2001 From: aweaver Date: Tue, 27 Sep 2022 12:52:38 +0200 Subject: [PATCH 2/2] Fix multiple addition of header Previous fix created an unwanted behaviour when calling stdheader several times during a rebase. This commit fixes this issue. Thus providing a cleaner solution for the original fix. --- plugin/stdheader.vim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin/stdheader.vim b/plugin/stdheader.vim index 7a09d87..dd0f02e 100644 --- a/plugin/stdheader.vim +++ b/plugin/stdheader.vim @@ -126,15 +126,16 @@ function! s:insert() endfunction function! s:update() - if s:rebasing() - return 1 - endif call s:filetype() if getline(9) =~ s:start . repeat(' ', s:margin - strlen(s:start)) . "Updated: " if &mod - call setline(9, s:line(9)) + if s:not_rebasing() + call setline(9, s:line(9)) + endif + endif + if s:not_rebasing() + call setline(4, s:line(4)) endif - call setline(4, s:line(4)) return 0 endif return 1 @@ -146,11 +147,11 @@ function! s:stdheader() endif endfunction -function! s:rebasing() +function! s:not_rebasing() if system("ls `git rev-parse --git-dir 2>/dev/null` | grep rebase | wc -l") - return 1 + return 0 endif - return 0 + return 1 endfunction " Bind command and shortcut