nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 1532bf1922c251b569d0bc17cf4a87d4c414bec1
parent ac544460e43db9366c96d42a7bd03c048822361a
Author: Martin Grenfell <martin_grenfell@msn.com>
Date:   Sun, 29 Jun 2008 00:41:34 +1200

move the bookmark->string code into the bookmark class

Diffstat:
Mplugin/NERD_tree.vim | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -281,6 +281,16 @@ function! s:oBookmark.New(name, path) dict
     let newBookmark.path = a:path
     return newBookmark
 endfunction
+" Function: oBookmark.Str()   {{{3
+" Get the string that should be rendered in the view for this bookmark
+function! s:oBookmark.Str() dict
+    let pathStrMaxLen = 26 - len(self.name)
+    let pathStr = self.path.StrForOS(0)
+    if len(pathStr) > pathStrMaxLen
+        let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
+    endif
+    return '>' . self.name . ' [' . pathStr . ']'
+endfunction
 " Function: oBookmark.Write()   {{{3
 " Class method to write all bookmarks to the bookmarks file
 function! s:oBookmark.Write() dict
@@ -2363,14 +2373,7 @@ function! s:RenderBookmarks()
     call cursor(line(".")+1, col("."))
 
     for i in s:oBookmark.Bookmarks()
-
-        let pathStrMaxLen = 26 - len(i.name)
-        let pathStr = i.path.StrForOS(0)
-        if len(pathStr) > pathStrMaxLen
-            let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
-        endif
-
-        call setline(line(".")+1,'>' . i.name . ' [' . pathStr . ']')
+        call setline(line(".")+1, i.Str())
         call cursor(line(".")+1, col("."))
     endfor