From f5a20e537935743416374e303b0165b99bcb8ac7 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 2 Jul 2008 21:15:28 +1200 Subject: [PATCH] fix some bugs when dealing with invalid bookmarks --- plugin/NERD_tree.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 4ee3698..95494ab 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -211,15 +211,15 @@ function! s:oBookmark.CacheBookmarks() dict try let bookmark = s:oBookmark.New(name, s:oPath.New(path)) + call add(bookmarks, bookmark) catch /NERDTree.Path.InvalidArguments/ let invalidBookmarksFound += 1 endtry - call add(bookmarks, bookmark) endfor let g:NERDTreeBookmarks = bookmarks if invalidBookmarksFound call s:Echo(invalidBookmarksFound . " invalid bookmarks were read and discarded") - call s:WriteBookmarks() + call s:oBookmark.Write() endif endif endfunction @@ -278,7 +278,7 @@ endfunction " Create a new bookmark object with the given name and path object function! s:oBookmark.New(name, path) dict if a:name !~ '^[0-9a-zA-Z_]*$' - throw "NERDTree.IllegalBookmarkName illegal name:" a:name + throw "NERDTree.IllegalBookmarkName illegal name:" . a:name endif let newBookmark = copy(self) @@ -2797,8 +2797,12 @@ endfunction function! s:BookmarkNode(name) let currentNode = s:GetSelectedNode() if currentNode != {} - call currentNode.Bookmark(a:name) - call s:RenderView() + try + call currentNode.Bookmark(a:name) + call s:RenderView() + catch /NERDTree.IllegalBookmarkName/ + call s:Echo("bookmark names must be made up of alpha numeric characters and underscores") + endtry else call s:Echo("select a node first") endif