mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
add proof of concept for path flags API and add git modified flags
This commit is contained in:
@@ -24,6 +24,13 @@ 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")
|
||||
@@ -33,8 +40,10 @@ function! s:Path.bookmarkNames()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path.cacheDisplayString() {{{1
|
||||
function! s:Path.cacheDisplayString()
|
||||
let self.cachedDisplayString = self.getLastPathComponent(1)
|
||||
function! s:Path.cacheDisplayString() abort
|
||||
let self.cachedDisplayString = self._flagString()
|
||||
|
||||
let self.cachedDisplayString .= self.getLastPathComponent(1)
|
||||
|
||||
if self.isExecutable
|
||||
let self.cachedDisplayString = self.cachedDisplayString . '*'
|
||||
@@ -350,6 +359,15 @@ 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()
|
||||
@@ -460,6 +478,7 @@ function! s:Path.New(path)
|
||||
call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path))
|
||||
|
||||
let newPath.cachedDisplayString = ""
|
||||
let newPath._flags = []
|
||||
|
||||
return newPath
|
||||
endfunction
|
||||
@@ -480,6 +499,14 @@ 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
|
||||
"
|
||||
"
|
||||
@@ -537,6 +564,7 @@ endfunction
|
||||
"FUNCTION: Path.refresh() {{{1
|
||||
function! s:Path.refresh()
|
||||
call self.readInfoFromDisk(self.str())
|
||||
call g:NERDTreeRefreshNotifier.NotifyListeners(self)
|
||||
call self.cacheDisplayString()
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user