aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-08-31 17:53:09 +0200
committersrdusr <trevorgray@srdusr.com>2023-08-31 17:53:09 +0200
commit0099ea4927b9b5e7599d33cbc835ede09184b66b (patch)
tree1882b3443238a4becf8da55315e35367c36a633d
parent030ade0e07d9c6c9b6a9d0984204c6214d365e38 (diff)
downloaddotfiles-0099ea4927b9b5e7599d33cbc835ede09184b66b.tar.gz
dotfiles-0099ea4927b9b5e7599d33cbc835ede09184b66b.zip
Still trying to fix annoying timestamp issue
-rw-r--r--autoload/utils.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/autoload/utils.vim b/autoload/utils.vim
index 3bb83bf..f11a769 100644
--- a/autoload/utils.vim
+++ b/autoload/utils.vim
@@ -166,6 +166,24 @@ autocmd! BufNewFile,BufRead *.* call utils#DisableBr()
"-------------------------------------------------
" Annoying timestamp issue on write (The file has been changed since reading it...)
+"function! utils#ProcessFileChangedShell()
+" if v:fcs_reason == 'mode' || v:fcs_reason == 'time'
+" let v:fcs_choice = ''
+" else
+" let v:fcs_choice = 'ask'
+" endif
+"endfunction
+"autocmd FileChangedShell <buffer> call utils#ProcessFileChangedShell()
+"
+"let lastline = line('$')
+"let bufcontents = getline(1, lastline)
+"edit!
+"call setline(1, bufcontents)
+"if line('$') > lastline
+" execute lastline+1.',$:d _'
+"endif
+
+" Annoying timestamp issue on write (The file has been changed since reading it...)
function! utils#ProcessFileChangedShell()
if v:fcs_reason == 'mode' || v:fcs_reason == 'time'
let v:fcs_choice = ''
@@ -173,7 +191,21 @@ function! utils#ProcessFileChangedShell()
let v:fcs_choice = 'ask'
endif
endfunction
+
+" Triggered when the file is changed externally
autocmd FileChangedShell <buffer> call utils#ProcessFileChangedShell()
+" Triggered before writing the buffer to the file
+autocmd BufWritePre <buffer> call utils#BeforeWrite()
+
+function! utils#BeforeWrite()
+ let lastline = line('$')
+ let bufcontents = getline(1, lastline)
+ edit!
+ call setline(1, bufcontents)
+ if line('$') > lastline
+ execute lastline+1.',$:d _'
+ endif
+endfunction
"-------------------------------------------------