allow flags to be scoped to a plugin

Add new FlagSet class and init each Path with one.

Call Path.flagSet.addFlag(scope, flag) instead of Path.addFlag(flag)
This commit is contained in:
Martin Grenfell
2014-07-05 20:51:21 +01:00
parent a7428eba38
commit 32cf3ee62d
4 changed files with 61 additions and 28 deletions

View File

@@ -24,13 +24,6 @@ function! s:Path.AbsolutePathFor(str)
return toReturn
endfunction
"FUNCTION: Path.addFlag(flag) {{{1
function! s:Path.addFlag(flag)
if index(self._flags, a:flag) == -1
call add(self._flags, a:flag)
endif
endfunction
"FUNCTION: Path.bookmarkNames() {{{1
function! s:Path.bookmarkNames()
if !exists("self._bookmarkNames")
@@ -41,7 +34,7 @@ endfunction
"FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self._flagString()
let self.cachedDisplayString = self.flagSet.renderToString()
let self.cachedDisplayString .= self.getLastPathComponent(1)
@@ -359,15 +352,6 @@ function! s:Path.getSortOrderIndex()
return s:NERDTreeSortStarIndex
endfunction
"FUNCTION: Path._flagString() {{{1
function! s:Path._flagString()
if empty(self._flags)
return ""
endif
return '[' . join(self._flags, ',') . ']'
endfunction
"FUNCTION: Path.isUnixHiddenFile() {{{1
"check for unix hidden files
function! s:Path.isUnixHiddenFile()
@@ -478,7 +462,7 @@ function! s:Path.New(path)
call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path))
let newPath.cachedDisplayString = ""
let newPath._flags = []
let newPath.flagSet = g:NERDTreeFlagSet.New()
return newPath
endfunction
@@ -499,14 +483,6 @@ function! s:Path.Resolve(path)
return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
endfunction
"FUNCTION: Path.removeFlag(flag) {{{1
function! s:Path.removeFlag(flag)
let i = index(self._flags, a:flag)
if i >= 0
call remove(self._flags, i)
endif
endfunction
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1
"
"