diff options
author | Tyler Szabo <tyler@szabomail.ca> | 2020-12-23 02:17:03 -0800 |
---|---|---|
committer | Tyler Szabo <tyler@szabomail.ca> | 2020-12-23 02:39:55 -0800 |
commit | 08d1974ff1c61b5e4de5a4991662c81c1672c692 (patch) | |
tree | f92c0141447401613803758aa266c7698490cdd3 | |
parent | 268de84cda9278c5f24a38664df00750a195833b (diff) | |
download | todo.txt-vim-08d1974ff1c61b5e4de5a4991662c81c1672c692.zip |
Handle error when Done file is same file
-rw-r--r-- | autoload/todo.vim | 10 |
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) |