Skip to content

Commit

Permalink
Merge pull request #165 from VimfanTPdvorak/enhancepersist
Browse files Browse the repository at this point in the history
Improve nvim/vim to immediately create the undofile after :UndotreePersistUndo executed.
  • Loading branch information
mbbill committed Oct 23, 2023
2 parents 7b505f1 + 5fc3931 commit 3ff3aa0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions autoload/undotree.vim
Expand Up @@ -1463,14 +1463,24 @@ function! undotree#UndotreeFocus() abort
endfunction

function! undotree#UndotreePersistUndo(goSetUndofile = 0) abort
call s:log("undotree#UndotreePersistUndo(" .. a:goSetUndofile .. ")")
if ! &undofile
if !isdirectory(g:undotree_UndoDir)
call mkdir(g:undotree_UndoDir, 'p', 0700)
call s:log(" > [Dir " .. g:undotree_UndoDir .. "] created.")
endif
exe "set undodir=" .. g:undotree_UndoDir
call s:log(" > [set undodir=" .. g:undotree_UndoDir .. "] executed.")
if filereadable(undofile(expand('%'))) || a:goSetUndofile
setlocal undofile
call s:log(" > [setlocal undofile] executed")
endif
if a:goSetUndofile
silent! write
echo "A persistence undo file has been created."
endif
else
call s:log(" > Undofile has been set. Do nothing.")
endif
endfunction

Expand Down

0 comments on commit 3ff3aa0

Please sign in to comment.