From 176b551af0cf5ce34c4d74a0d15aa48943471a5e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 16 Jun 2008 20:33:17 +1200 Subject: [PATCH] handle invalid bookmarks in bookmarks file --- plugin/NERD_tree.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 0fe5af9..84f988d 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1500,11 +1500,21 @@ function! s:ReadBookmarks() if filereadable(g:NERDTreeBookmarksFile) let bookmarks = s:GetBookmarks() let bookmarkStrings = readfile(g:NERDTreeBookmarksFile) + let invalidBookmarksFound = 0 for i in bookmarkStrings let key = substitute(i, '^\(\w.\{-}\) .*$', '\1', '') let path = substitute(i, '^\w.\{-} \(.*\)$', '\1', '') - let bookmarks[key] = s:oPath.New(path) + + try + let bookmarks[key] = s:oPath.New(path) + catch /NERDTree.Path.InvalidArguments/ + let invalidBookmarksFound = 1 + endtry endfor + if invalidBookmarksFound + call s:Echo("Invalid bookmarks were read and discarded") + call s:WriteBookmarks() + endif endif endfunction " Function: s:TreeExistsForTab() {{{2