diff options
-rw-r--r-- | vim/plugin/undoskip.vim | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/vim/plugin/undoskip.vim b/vim/plugin/undoskip.vim index 924c01f4..af66f480 100644 --- a/vim/plugin/undoskip.vim +++ b/vim/plugin/undoskip.vim @@ -4,23 +4,26 @@ " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('loaded_undoskip') || &compatible || !has('persistent_undo') +if exists('loaded_undoskip') || &compatible + finish +endif +if !has('persistent_undo') || !exists('*glob2regpat') finish endif let loaded_undoskip = 1 " Set default list of patterns to exclude; mirror documented 'backupskip' " behavior -if !exists('g:undoskip_patterns') - let g:undoskip_patterns = [] +if !exists('g:undoskip') + let g:undoskip = [] if has('mac') - call add(g:undoskip_patterns, '^/private/tmp/.') + call add(g:undoskip, '/private/tmp/*') elseif has('unix') - call add(g:undoskip_patterns, '^/tmp/.') + call add(g:undoskip, '/tmp/*') endif - call extend(g:undoskip_patterns, map( + call extend(g:undoskip, map( \ filter([$TMPDIR, $TMP, $TEMP], 'v:val !=# '''''), - \ '''\V\^''.escape(v:val, ''\'').''/\.''' + \ 'v:val.''/*''' \)) endif @@ -35,8 +38,8 @@ function s:CheckUndoSkip() abort " Get the path from the buffer name; if that path matches any of the " patterns, don't save undo data let path = bufname('%') - for pattern in g:undoskip_patterns - if path =~# pattern + for glob in g:undoskip + if path =~# glob2regpat(glob) return 0 endif endfor |