diff options
author | David Beniamine <david.beniamine@tetras-libre.fr> | 2020-12-24 10:57:43 +0000 |
---|---|---|
committer | David Beniamine <david.beniamine@tetras-libre.fr> | 2020-12-24 10:57:43 +0000 |
commit | c8e97f68468fce686257287aae9f43a44cb1b6ac (patch) | |
tree | b3961b9539710d6be28816ea26c98e23f1325ffd | |
parent | 145bcfe067c00650c8805dd58b0c96c74cdd6277 (diff) | |
parent | 08d1974ff1c61b5e4de5a4991662c81c1672c692 (diff) | |
download | todo.txt-vim-c8e97f68468fce686257287aae9f43a44cb1b6ac.zip |
Merge branch 'fix_donefile' into 'master'
Handle error when Done file is same file
See merge request dbeniamine/todo.txt-vim!44
-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 d8fb172..c6b49d4 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) |