summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Szabo <tyler@szabomail.ca>2020-12-23 02:17:03 -0800
committerTyler Szabo <tyler@szabomail.ca>2020-12-23 02:39:55 -0800
commit08d1974ff1c61b5e4de5a4991662c81c1672c692 (patch)
treef92c0141447401613803758aa266c7698490cdd3
parent268de84cda9278c5f24a38664df00750a195833b (diff)
downloadtodo.txt-vim-08d1974ff1c61b5e4de5a4991662c81c1672c692.zip
Handle error when Done file is same file
-rw-r--r--autoload/todo.vim10
1 files changed, 8 insertions, 2 deletions
diff --git a/autoload/todo.vim b/autoload/todo.vim
index e53c941..320440b 100644
--- a/autoload/todo.vim
+++ b/autoload/todo.vim
@@ -141,17 +141,23 @@ endfunction
function! todo#RemoveCompleted()
" Check if we can write to done.txt before proceeding.
let l:target_dir = expand('%:p:h')
+ let l:currentfile=expand('%:t')
+
if exists("g:TodoTxtForceDoneName")
let l:done=g:TodoTxtForceDoneName
else
- let l:currentfile=expand('%:t')
-
if l:currentfile =~ '[Tt]oday.txt'
let l:done=substitute(substitute(l:currentfile,'today','done-today',''),'Today','Done-Today','')
else
let l:done=substitute(substitute(l:currentfile,'todo','done',''),'Todo','Done','')
endif
endif
+
+ if l:done == l:currentfile
+ echoerr "Done file is same as current file: ".l:done
+ return
+ endif
+
let l:done_file = l:target_dir.'/'.l:done
echo "Writing to ".l:done_file
if !filewritable(l:done_file) && !filewritable(l:target_dir)