Skip to content

Commit

Permalink
merge bookmark name caching with path string caching
Browse files Browse the repository at this point in the history
We needed to change how the bookmark name caching was done to work with
the new path-display-string caching. It has now been merged into path
string caching.
  • Loading branch information
Martin Grenfell committed Jul 1, 2008
1 parent 9d5a940 commit f2b2327
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
2 changes: 2 additions & 0 deletions doc/NERD_tree.txt
Expand Up @@ -882,6 +882,8 @@ fridge for later ;)
- applied a patch from Matan Nassau to add the NERDTreeQuitOnOpen option
which closes the tree window after opening a file. See :help
NERDTreeQuitOnOpen.
- optimised the nerd tree rendering. Now it takes just over 1/3 of the time
it previously took to render.
- fix to window resizing when opening a file when NERD tree is the only
window open

Expand Down
66 changes: 28 additions & 38 deletions plugin/NERD_tree.vim
Expand Up @@ -247,7 +247,7 @@ function! s:oBookmark.Delete() dict
endtry
call remove(s:oBookmark.Bookmarks(), index(s:oBookmark.Bookmarks(), self))
if !empty(node)
call node.path.CacheBookmarks()
call node.path.CacheDisplayString()
endif
endfunction
" FUNCTION: oBookmark.GetNode(searchFromAbsoluteRoot) {{{3
Expand Down Expand Up @@ -326,12 +326,12 @@ let s:oTreeFileNode = {}
function! s:oTreeFileNode.Bookmark(name) dict
try
let oldMarkedNode = s:oBookmark.GetNodeForName(a:name, 1)
call oldMarkedNode.path.UncacheBookmark(a:name)
call oldMarkedNode.path.CacheDisplayString()
catch /NERDTree.Bookmark\(DoesntExist\|NotFound\)/
endtry

call s:oBookmark.AddBookmark(a:name, self.path)
call self.path.CacheBookmarks()
call self.path.CacheDisplayString()
call s:oBookmark.Write()
endfunction
"FUNCTION: oTreeFileNode.CacheParent {{{3
Expand Down Expand Up @@ -364,7 +364,7 @@ function! s:oTreeFileNode.ClearBookmarks() dict
call i.Delete()
end
endfor
call self.path.CacheBookmarks()
call self.path.CacheDisplayString()
endfunction
"FUNCTION: oTreeFileNode.Copy(dest) {{{3
function! s:oTreeFileNode.Copy(dest) dict
Expand Down Expand Up @@ -991,19 +991,35 @@ let s:oPath = {}
"FUNCTION: oPath.BookmarkNames() {{{3
function! s:oPath.BookmarkNames() dict
if !exists("self.bookmark")
call self.CacheBookmarks()
call self.CacheDisplayString()
endif
return self.bookmarkNames
endfunction
"FUNCTION: oPath.CacheBookmarks() {{{3
function! s:oPath.CacheBookmarks() dict
let self.bookmarkNames = []
"FUNCTION: oPath.CacheDisplayString() {{{3
function! s:oPath.CacheDisplayString() dict
let self.cachedDisplayString = self.GetLastPathComponent(1)

if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
endif

let bookmarkNames = []
for i in s:oBookmark.Bookmarks()
if i.path.Equals(self)
call add(self.bookmarkNames, i.name)
call add(bookmarkNames, i.name)
endif
endfor
return self.bookmarkNames
if !empty(bookmarkNames)
let self.cachedDisplayString .= ' {' . join(bookmarkNames) . '}'
endif

if self.isSymLink
let self.cachedDisplayString .= ' -> ' . self.symLinkDest
endif

if self.isReadOnly
let self.cachedDisplayString .= ' [RO]'
endif
endfunction
"FUNCTION: oPath.ChangeToDir() {{{3
function! s:oPath.ChangeToDir() dict
Expand Down Expand Up @@ -1368,8 +1384,7 @@ endfunction
"FUNCTION: oPath.Refresh() {{{3
function! s:oPath.Refresh() dict
call self.ReadInfoFromDisk(self.StrForOS(0))
call self.CacheBookmarks()
let self.cachedDisplayString = ""
call self.CacheDisplayString()
endfunction

"FUNCTION: oPath.Rename() {{{3
Expand Down Expand Up @@ -1437,23 +1452,7 @@ endfunction
"a string that can be used in the view to represent this path
function! s:oPath.StrDisplay() dict
if self.cachedDisplayString == ""
let self.cachedDisplayString = self.GetLastPathComponent(1)

if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
endif

if !empty(self.BookmarkNames())
let self.cachedDisplayString .= ' {' . join(self.BookmarkNames(), ',') . '}'
endif

if self.isSymLink
let self.cachedDisplayString .= ' -> ' . self.symLinkDest
endif

if self.isReadOnly
let self.cachedDisplayString .= ' [RO]'
endif
call self.CacheDisplayString()
endif

return self.cachedDisplayString
Expand Down Expand Up @@ -1522,15 +1521,6 @@ function! s:oPath.StrTrunk() dict
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
endfunction

"FUNCTION: oPath.UncacheBookmark(name){{{3
"remove the given bookmark from this paths cached bookmarks
function! s:oPath.UncacheBookmark(name) dict
let bookmarks = self.BookmarkNames()
let i = index(bookmarks, a:name)
if i != -1
call remove(bookmarks, i)
endif
endfunction
"FUNCTION: oPath.WinToUnixPath(pathstr){{{3
"Takes in a windows path and returns the unix equiv
"
Expand Down

0 comments on commit f2b2327

Please sign in to comment.