Skip to content
This repository
Browse code

fix some bugs when dealing with invalid bookmarks

  • Loading branch information...
commit f5a20e537935743416374e303b0165b99bcb8ac7 1 parent a0573c5
Martin Grenfell authored July 02, 2008

Showing 1 changed file with 9 additions and 5 deletions. Show diff stats Hide diff stats

  1. 14  plugin/NERD_tree.vim
14  plugin/NERD_tree.vim
@@ -211,15 +211,15 @@ function! s:oBookmark.CacheBookmarks() dict
211 211
 
212 212
             try
213 213
                 let bookmark = s:oBookmark.New(name, s:oPath.New(path))
  214
+                call add(bookmarks, bookmark)
214 215
             catch /NERDTree.Path.InvalidArguments/
215 216
                 let invalidBookmarksFound += 1
216 217
             endtry
217  
-            call add(bookmarks, bookmark)
218 218
         endfor
219 219
         let g:NERDTreeBookmarks = bookmarks
220 220
         if invalidBookmarksFound
221 221
             call s:Echo(invalidBookmarksFound . " invalid bookmarks were read and discarded")
222  
-            call s:WriteBookmarks()
  222
+            call s:oBookmark.Write()
223 223
         endif
224 224
     endif
225 225
 endfunction
@@ -278,7 +278,7 @@ endfunction
278 278
 " Create a new bookmark object with the given name and path object
279 279
 function! s:oBookmark.New(name, path) dict
280 280
     if a:name !~ '^[0-9a-zA-Z_]*$'
281  
-        throw "NERDTree.IllegalBookmarkName illegal name:" a:name
  281
+        throw "NERDTree.IllegalBookmarkName illegal name:" . a:name
282 282
     endif
283 283
 
284 284
     let newBookmark = copy(self)
@@ -2797,8 +2797,12 @@ endfunction
2797 2797
 function! s:BookmarkNode(name)
2798 2798
     let currentNode = s:GetSelectedNode()
2799 2799
     if currentNode != {}
2800  
-        call currentNode.Bookmark(a:name)
2801  
-        call s:RenderView()
  2800
+        try
  2801
+            call currentNode.Bookmark(a:name)
  2802
+            call s:RenderView()
  2803
+        catch /NERDTree.IllegalBookmarkName/
  2804
+            call s:Echo("bookmark names must be made up of alpha numeric characters and underscores")
  2805
+        endtry
2802 2806
     else
2803 2807
         call s:Echo("select a node first")
2804 2808
     endif

0 notes on commit f5a20e5

Please sign in to comment.
Something went wrong with that request. Please try again.