mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 22:08:24 +08:00
merge bookmark name caching with path string caching
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.
This commit is contained in:
parent
9d5a940be3
commit
f2b2327c24
|
@ -882,6 +882,8 @@ fridge for later ;)
|
||||||
- applied a patch from Matan Nassau to add the NERDTreeQuitOnOpen option
|
- applied a patch from Matan Nassau to add the NERDTreeQuitOnOpen option
|
||||||
which closes the tree window after opening a file. See :help
|
which closes the tree window after opening a file. See :help
|
||||||
NERDTreeQuitOnOpen.
|
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
|
- fix to window resizing when opening a file when NERD tree is the only
|
||||||
window open
|
window open
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ function! s:oBookmark.Delete() dict
|
||||||
endtry
|
endtry
|
||||||
call remove(s:oBookmark.Bookmarks(), index(s:oBookmark.Bookmarks(), self))
|
call remove(s:oBookmark.Bookmarks(), index(s:oBookmark.Bookmarks(), self))
|
||||||
if !empty(node)
|
if !empty(node)
|
||||||
call node.path.CacheBookmarks()
|
call node.path.CacheDisplayString()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: oBookmark.GetNode(searchFromAbsoluteRoot) {{{3
|
" FUNCTION: oBookmark.GetNode(searchFromAbsoluteRoot) {{{3
|
||||||
|
@ -326,12 +326,12 @@ let s:oTreeFileNode = {}
|
||||||
function! s:oTreeFileNode.Bookmark(name) dict
|
function! s:oTreeFileNode.Bookmark(name) dict
|
||||||
try
|
try
|
||||||
let oldMarkedNode = s:oBookmark.GetNodeForName(a:name, 1)
|
let oldMarkedNode = s:oBookmark.GetNodeForName(a:name, 1)
|
||||||
call oldMarkedNode.path.UncacheBookmark(a:name)
|
call oldMarkedNode.path.CacheDisplayString()
|
||||||
catch /NERDTree.Bookmark\(DoesntExist\|NotFound\)/
|
catch /NERDTree.Bookmark\(DoesntExist\|NotFound\)/
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
call s:oBookmark.AddBookmark(a:name, self.path)
|
call s:oBookmark.AddBookmark(a:name, self.path)
|
||||||
call self.path.CacheBookmarks()
|
call self.path.CacheDisplayString()
|
||||||
call s:oBookmark.Write()
|
call s:oBookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: oTreeFileNode.CacheParent {{{3
|
"FUNCTION: oTreeFileNode.CacheParent {{{3
|
||||||
|
@ -364,7 +364,7 @@ function! s:oTreeFileNode.ClearBookmarks() dict
|
||||||
call i.Delete()
|
call i.Delete()
|
||||||
end
|
end
|
||||||
endfor
|
endfor
|
||||||
call self.path.CacheBookmarks()
|
call self.path.CacheDisplayString()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: oTreeFileNode.Copy(dest) {{{3
|
"FUNCTION: oTreeFileNode.Copy(dest) {{{3
|
||||||
function! s:oTreeFileNode.Copy(dest) dict
|
function! s:oTreeFileNode.Copy(dest) dict
|
||||||
|
@ -991,19 +991,35 @@ let s:oPath = {}
|
||||||
"FUNCTION: oPath.BookmarkNames() {{{3
|
"FUNCTION: oPath.BookmarkNames() {{{3
|
||||||
function! s:oPath.BookmarkNames() dict
|
function! s:oPath.BookmarkNames() dict
|
||||||
if !exists("self.bookmark")
|
if !exists("self.bookmark")
|
||||||
call self.CacheBookmarks()
|
call self.CacheDisplayString()
|
||||||
endif
|
endif
|
||||||
return self.bookmarkNames
|
return self.bookmarkNames
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: oPath.CacheBookmarks() {{{3
|
"FUNCTION: oPath.CacheDisplayString() {{{3
|
||||||
function! s:oPath.CacheBookmarks() dict
|
function! s:oPath.CacheDisplayString() dict
|
||||||
let self.bookmarkNames = []
|
let self.cachedDisplayString = self.GetLastPathComponent(1)
|
||||||
|
|
||||||
|
if self.isExecutable
|
||||||
|
let self.cachedDisplayString = self.cachedDisplayString . '*'
|
||||||
|
endif
|
||||||
|
|
||||||
|
let bookmarkNames = []
|
||||||
for i in s:oBookmark.Bookmarks()
|
for i in s:oBookmark.Bookmarks()
|
||||||
if i.path.Equals(self)
|
if i.path.Equals(self)
|
||||||
call add(self.bookmarkNames, i.name)
|
call add(bookmarkNames, i.name)
|
||||||
endif
|
endif
|
||||||
endfor
|
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
|
endfunction
|
||||||
"FUNCTION: oPath.ChangeToDir() {{{3
|
"FUNCTION: oPath.ChangeToDir() {{{3
|
||||||
function! s:oPath.ChangeToDir() dict
|
function! s:oPath.ChangeToDir() dict
|
||||||
|
@ -1368,8 +1384,7 @@ endfunction
|
||||||
"FUNCTION: oPath.Refresh() {{{3
|
"FUNCTION: oPath.Refresh() {{{3
|
||||||
function! s:oPath.Refresh() dict
|
function! s:oPath.Refresh() dict
|
||||||
call self.ReadInfoFromDisk(self.StrForOS(0))
|
call self.ReadInfoFromDisk(self.StrForOS(0))
|
||||||
call self.CacheBookmarks()
|
call self.CacheDisplayString()
|
||||||
let self.cachedDisplayString = ""
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.Rename() {{{3
|
"FUNCTION: oPath.Rename() {{{3
|
||||||
|
@ -1437,23 +1452,7 @@ endfunction
|
||||||
"a string that can be used in the view to represent this path
|
"a string that can be used in the view to represent this path
|
||||||
function! s:oPath.StrDisplay() dict
|
function! s:oPath.StrDisplay() dict
|
||||||
if self.cachedDisplayString == ""
|
if self.cachedDisplayString == ""
|
||||||
let self.cachedDisplayString = self.GetLastPathComponent(1)
|
call self.CacheDisplayString()
|
||||||
|
|
||||||
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
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return self.cachedDisplayString
|
return self.cachedDisplayString
|
||||||
|
@ -1522,15 +1521,6 @@ function! s:oPath.StrTrunk() dict
|
||||||
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
||||||
endfunction
|
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
|
"FUNCTION: oPath.WinToUnixPath(pathstr){{{3
|
||||||
"Takes in a windows path and returns the unix equiv
|
"Takes in a windows path and returns the unix equiv
|
||||||
"
|
"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user