Fix lint warnings: use robust operators

This commit is contained in:
Caleb Maclennan 2019-12-31 09:29:58 +03:00
parent 45e33f2502
commit a722613f36
No known key found for this signature in database
GPG Key ID: 63CC496475267693
14 changed files with 120 additions and 120 deletions

View File

@ -15,7 +15,7 @@ function! nerdtree#version(...)
let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash()))
let l:line = 0 let l:line = 0
while l:line <= len(l:changelog) while l:line <= len(l:changelog)
if l:changelog[l:line] =~ '\d\+\.\d\+' if l:changelog[l:line] =~# '\d\+\.\d\+'
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
break break
@ -122,15 +122,15 @@ function! nerdtree#compareNodesBySortKey(n1, n2)
" Compare chunks upto common length. " Compare chunks upto common length.
" If chunks have different type, the one which has " If chunks have different type, the one which has
" integer type is the lesser. " integer type is the lesser.
if type(sortKey1[i]) == type(sortKey2[i]) if type(sortKey1[i]) ==# type(sortKey2[i])
if sortKey1[i] <# sortKey2[i] if sortKey1[i] <# sortKey2[i]
return - 1 return - 1
elseif sortKey1[i] ># sortKey2[i] elseif sortKey1[i] ># sortKey2[i]
return 1 return 1
endif endif
elseif type(sortKey1[i]) == v:t_number elseif type(sortKey1[i]) ==# v:t_number
return -1 return -1
elseif type(sortKey2[i]) == v:t_number elseif type(sortKey2[i]) ==# v:t_number
return 1 return 1
endif endif
let i = i + 1 let i = i + 1
@ -175,7 +175,7 @@ endfunction
" FUNCTION: nerdtree#has_opt(options, name) {{{2 " FUNCTION: nerdtree#has_opt(options, name) {{{2
function! nerdtree#has_opt(options, name) function! nerdtree#has_opt(options, name)
return has_key(a:options, a:name) && a:options[a:name] == 1 return has_key(a:options, a:name) && a:options[a:name] ==# 1
endfunction endfunction
" FUNCTION: nerdtree#loadClassFiles() {{{2 " FUNCTION: nerdtree#loadClassFiles() {{{2

View File

@ -146,7 +146,7 @@ endfunction
" Associate the current node with the given name " Associate the current node with the given name
function! nerdtree#ui_glue#bookmarkNode(...) function! nerdtree#ui_glue#bookmarkNode(...)
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
if currentNode != {} if currentNode !=# {}
let name = a:1 let name = a:1
if empty(name) if empty(name)
let name = currentNode.path.getLastPathComponent(0) let name = currentNode.path.getLastPathComponent(0)
@ -187,7 +187,7 @@ endfunction
function! nerdtree#ui_glue#clearBookmarks(bookmarks) function! nerdtree#ui_glue#clearBookmarks(bookmarks)
if a:bookmarks ==# '' if a:bookmarks ==# ''
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
if currentNode != {} if currentNode !=# {}
call currentNode.clearBookmarks() call currentNode.clearBookmarks()
endif endif
else else
@ -236,7 +236,7 @@ endfunction
" FUNCTION: s:closeTreeWindow() {{{1 " FUNCTION: s:closeTreeWindow() {{{1
" close the tree window " close the tree window
function! s:closeTreeWindow() function! s:closeTreeWindow()
if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() !=# -1
exec 'buffer ' . b:NERDTree.previousBuf() exec 'buffer ' . b:NERDTree.previousBuf()
else else
if winnr('$') > 1 if winnr('$') > 1
@ -258,7 +258,7 @@ function! s:deleteBookmark(bookmark)
echo | redraw echo | redraw
let l:selection = confirm(l:message, l:choices, 1, 'Warning') let l:selection = confirm(l:message, l:choices, 1, 'Warning')
if l:selection != 1 if l:selection !=# 1
call nerdtree#echo('bookmark not deleted') call nerdtree#echo('bookmark not deleted')
return return
endif endif
@ -335,7 +335,7 @@ endfunction
"Checks if the click should open the current node "Checks if the click should open the current node
function! s:handleLeftClick() function! s:handleLeftClick()
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
if currentNode != {} if currentNode !=# {}
"the dir arrows are multibyte chars, and vim's string functions only "the dir arrows are multibyte chars, and vim's string functions only
"deal with single bytes - so split the line up with the hack below and "deal with single bytes - so split the line up with the hack below and

View File

@ -93,7 +93,7 @@ function! s:Bookmark.CacheBookmarks(silent)
for i in bookmarkStrings for i in bookmarkStrings
"ignore blank lines "ignore blank lines
if i != '' if i !=# ''
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
@ -123,13 +123,13 @@ endfunction
" option. Supports the s:Bookmark.SortBookmarksList() method. " option. Supports the s:Bookmark.SortBookmarksList() method.
function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark)
let l:result = 0 let l:result = 0
if g:NERDTreeBookmarksSort == 1 if g:NERDTreeBookmarksSort ==# 1
if a:firstBookmark.name <? a:secondBookmark.name if a:firstBookmark.name <? a:secondBookmark.name
let l:result = -1 let l:result = -1
elseif a:firstBookmark.name >? a:secondBookmark.name elseif a:firstBookmark.name >? a:secondBookmark.name
let l:result = 1 let l:result = 1
endif endif
elseif g:NERDTreeBookmarksSort == 2 elseif g:NERDTreeBookmarksSort ==# 2
if a:firstBookmark.name <# a:secondBookmark.name if a:firstBookmark.name <# a:secondBookmark.name
let l:result = -1 let l:result = -1
elseif a:firstBookmark.name ># a:secondBookmark.name elseif a:firstBookmark.name ># a:secondBookmark.name
@ -198,7 +198,7 @@ endfunction
function! s:Bookmark.GetSelected() function! s:Bookmark.GetSelected()
let line = getline('.') let line = getline('.')
let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '')
if name != line if name !=# line
try try
return s:Bookmark.BookmarkFor(name) return s:Bookmark.BookmarkFor(name)
catch /^NERDTree.BookmarkNotFoundError/ catch /^NERDTree.BookmarkNotFoundError/

View File

@ -53,7 +53,7 @@ function! s:KeyMap.bind()
endif endif
let keymapInvokeString = escape(keymapInvokeString, '\') let keymapInvokeString = escape(keymapInvokeString, '\')
let premap = self.key == '<LeftRelease>' ? ' <LeftRelease>' : ' ' let premap = self.key ==# '<LeftRelease>' ? ' <LeftRelease>' : ' '
exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")<cr>' exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")<cr>'
endfunction endfunction
@ -66,7 +66,7 @@ endfunction
"FUNCTION: KeyMap.invoke() {{{1 "FUNCTION: KeyMap.invoke() {{{1
"Call the KeyMaps callback function "Call the KeyMaps callback function
function! s:KeyMap.invoke(...) function! s:KeyMap.invoke(...)
let Callback = type(self.callback) == type(function('tr')) ? self.callback : function(self.callback) let Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback)
if a:0 if a:0
call Callback(a:1) call Callback(a:1)
else else
@ -143,7 +143,7 @@ function! s:KeyMap.Create(options)
let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
"dont override other mappings unless the 'override' option is given "dont override other mappings unless the 'override' option is given
if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) if get(opts, 'override', 0) ==# 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope']))
return return
end end

View File

@ -45,12 +45,12 @@ function! s:MenuController.showMenu()
call self._restoreOptions() call self._restoreOptions()
" Redraw when Ctrl-C or Esc is received. " Redraw when Ctrl-C or Esc is received.
if !l:done || self.selection == -1 if !l:done || self.selection ==# -1
redraw! redraw!
endif endif
endtry endtry
if self.selection != -1 if self.selection !=# -1
let l:m = self._current() let l:m = self._current()
call l:m.execute() call l:m.execute()
endif endif
@ -73,7 +73,7 @@ function! s:MenuController._echoPrompt()
echo '=========================================================' echo '========================================================='
for i in range(0, len(self.menuItems)-1) for i in range(0, len(self.menuItems)-1)
if self.selection == i if self.selection ==# i
echo '> ' . self.menuItems[i].text echo '> ' . self.menuItems[i].text
else else
echo ' ' . self.menuItems[i].text echo ' ' . self.menuItems[i].text
@ -92,20 +92,20 @@ endfunction
"change the selection (if appropriate) and return 1 if the user has made "change the selection (if appropriate) and return 1 if the user has made
"their choice, 0 otherwise "their choice, 0 otherwise
function! s:MenuController._handleKeypress(key) function! s:MenuController._handleKeypress(key)
if a:key == g:NERDTreeMenuDown if a:key ==# g:NERDTreeMenuDown
call self._cursorDown() call self._cursorDown()
elseif a:key == g:NERDTreeMenuUp elseif a:key ==# g:NERDTreeMenuUp
call self._cursorUp() call self._cursorUp()
elseif a:key == nr2char(27) "escape elseif a:key ==# nr2char(27) "escape
let self.selection = -1 let self.selection = -1
return 1 return 1
elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j elseif a:key ==# "\r" || a:key ==# "\n" "enter and ctrl-j
return 1 return 1
else else
let index = self._nextIndexFor(a:key) let index = self._nextIndexFor(a:key)
if index != -1 if index !=# -1
let self.selection = index let self.selection = index
if len(self._allIndexesFor(a:key)) == 1 if len(self._allIndexesFor(a:key)) ==# 1
return 1 return 1
endif endif
endif endif
@ -120,7 +120,7 @@ function! s:MenuController._allIndexesFor(shortcut)
let toReturn = [] let toReturn = []
for i in range(0, len(self.menuItems)-1) for i in range(0, len(self.menuItems)-1)
if self.menuItems[i].shortcut == a:shortcut if self.menuItems[i].shortcut ==# a:shortcut
call add(toReturn, i) call add(toReturn, i)
endif endif
endfor endfor
@ -133,13 +133,13 @@ endfunction
"current cursor location and wraps around to the top again if need be "current cursor location and wraps around to the top again if need be
function! s:MenuController._nextIndexFor(shortcut) function! s:MenuController._nextIndexFor(shortcut)
for i in range(self.selection+1, len(self.menuItems)-1) for i in range(self.selection+1, len(self.menuItems)-1)
if self.menuItems[i].shortcut == a:shortcut if self.menuItems[i].shortcut ==# a:shortcut
return i return i
endif endif
endfor endfor
for i in range(0, self.selection) for i in range(0, self.selection)
if self.menuItems[i].shortcut == a:shortcut if self.menuItems[i].shortcut ==# a:shortcut
return i return i
endif endif
endfor endfor

View File

@ -37,13 +37,13 @@ function! s:NERDTree.Close()
return return
endif endif
if winnr('$') != 1 if winnr('$') !=# 1
" Use the window ID to identify the currently active window or fall " Use the window ID to identify the currently active window or fall
" back on the buffer ID if win_getid/win_gotoid are not available, in " back on the buffer ID if win_getid/win_gotoid are not available, in
" which case we'll focus an arbitrary window showing the buffer. " which case we'll focus an arbitrary window showing the buffer.
let l:useWinId = exists('*win_getid') && exists('*win_gotoid') let l:useWinId = exists('*win_getid') && exists('*win_gotoid')
if winnr() == s:NERDTree.GetWinNum() if winnr() ==# s:NERDTree.GetWinNum()
call nerdtree#exec('wincmd p', 1) call nerdtree#exec('wincmd p', 1)
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('')
call nerdtree#exec('wincmd p', 1) call nerdtree#exec('wincmd p', 1)
@ -160,17 +160,17 @@ endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1 "FUNCTION: s:NERDTree.IsOpen() {{{1
function! s:NERDTree.IsOpen() function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1 return s:NERDTree.GetWinNum() !=# -1
endfunction endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1 "FUNCTION: s:NERDTree.isTabTree() {{{1
function! s:NERDTree.isTabTree() function! s:NERDTree.isTabTree()
return self._type == 'tab' return self._type ==# 'tab'
endfunction endfunction
"FUNCTION: s:NERDTree.isWinTree() {{{1 "FUNCTION: s:NERDTree.isWinTree() {{{1
function! s:NERDTree.isWinTree() function! s:NERDTree.isWinTree()
return self._type == 'window' return self._type ==# 'window'
endfunction endfunction
"FUNCTION: s:NERDTree.MustBeOpen() {{{1 "FUNCTION: s:NERDTree.MustBeOpen() {{{1

View File

@ -45,7 +45,7 @@ function! s:Opener._checkToCloseTree(newtab)
return return
endif endif
if (a:newtab && self._where == 't') || !a:newtab if (a:newtab && self._where ==# 't') || !a:newtab
call g:NERDTree.CloseIfQuitOnOpen() call g:NERDTree.CloseIfQuitOnOpen()
endif endif
endfunction endfunction
@ -56,7 +56,7 @@ function! s:Opener._firstUsableWindow()
let i = 1 let i = 1
while i <= winnr('$') while i <= winnr('$')
let bnum = winbufnr(i) let bnum = winbufnr(i)
if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' if bnum !=# -1 && getbufvar(bnum, '&buftype') ==# ''
\ && !getwinvar(i, '&previewwindow') \ && !getwinvar(i, '&previewwindow')
\ && (!getbufvar(bnum, '&modified') || &hidden) \ && (!getbufvar(bnum, '&modified') || &hidden)
return i return i
@ -70,23 +70,23 @@ endfunction
" FUNCTION: Opener._gotoTargetWin() {{{1 " FUNCTION: Opener._gotoTargetWin() {{{1
function! s:Opener._gotoTargetWin() function! s:Opener._gotoTargetWin()
if b:NERDTree.isWinTree() if b:NERDTree.isWinTree()
if self._where == 'v' if self._where ==# 'v'
call self._newVSplit() call self._newVSplit()
elseif self._where == 'h' elseif self._where ==# 'h'
call self._newSplit() call self._newSplit()
elseif self._where == 't' elseif self._where ==# 't'
tabnew tabnew
endif endif
else else
call self._checkToCloseTree(1) call self._checkToCloseTree(1)
if self._where == 'v' if self._where ==# 'v'
call self._newVSplit() call self._newVSplit()
elseif self._where == 'h' elseif self._where ==# 'h'
call self._newSplit() call self._newSplit()
elseif self._where == 't' elseif self._where ==# 't'
tabnew tabnew
elseif self._where == 'p' elseif self._where ==# 'p'
call self._previousWindow() call self._previousWindow()
endif endif
@ -108,7 +108,7 @@ function! s:Opener._isWindowUsable(winnumber)
let oldwinnr = winnr() let oldwinnr = winnr()
call nerdtree#exec(a:winnumber . 'wincmd p', 1) call nerdtree#exec(a:winnumber . 'wincmd p', 1)
let specialWindow = getbufvar('%', '&buftype') != '' || getwinvar('%', '&previewwindow') let specialWindow = getbufvar('%', '&buftype') !=# '' || getwinvar('%', '&previewwindow')
let modified = &modified let modified = &modified
call nerdtree#exec(oldwinnr . 'wincmd p', 1) call nerdtree#exec(oldwinnr . 'wincmd p', 1)
@ -247,7 +247,7 @@ function! s:Opener._openDirectory(node)
else else
if empty(self._where) if empty(self._where)
call b:NERDTree.changeRoot(a:node) call b:NERDTree.changeRoot(a:node)
elseif self._where == 't' elseif self._where ==# 't'
call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
else else
call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) call g:NERDTreeCreator.CreateWindowTree(a:node.path.str())
@ -296,13 +296,13 @@ function! s:Opener._reuseWindow()
"check the current tab for the window "check the current tab for the window
let winnr = bufwinnr('^' . self._path.str() . '$') let winnr = bufwinnr('^' . self._path.str() . '$')
if winnr != -1 if winnr !=# -1
call nerdtree#exec(winnr . 'wincmd w', 0) call nerdtree#exec(winnr . 'wincmd w', 0)
call self._checkToCloseTree(0) call self._checkToCloseTree(0)
return 1 return 1
endif endif
if self._reuse == 'currenttab' if self._reuse ==# 'currenttab'
return 0 return 0
endif endif

View File

@ -25,7 +25,7 @@ function! s:Path.AbsolutePathFor(pathStr)
if l:prependWorkingDir if l:prependWorkingDir
let l:result = getcwd() let l:result = getcwd()
if l:result[-1:] == s:Path.Slash() if l:result[-1:] ==# s:Path.Slash()
let l:result = l:result . a:pathStr let l:result = l:result . a:pathStr
else else
let l:result = l:result . s:Path.Slash() . a:pathStr let l:result = l:result . s:Path.Slash() . a:pathStr
@ -57,7 +57,7 @@ function! s:Path.cacheDisplayString() abort
call add(self._bookmarkNames, i.name) call add(self._bookmarkNames, i.name)
endif endif
endfor endfor
if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks ==# 1
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}'
endif endif
@ -87,7 +87,7 @@ function! s:Path.changeToDir()
endif endif
try try
if g:NERDTreeUseTCD && exists(':tcd') == 2 if g:NERDTreeUseTCD && exists(':tcd') ==# 2
execute 'tcd ' . dir execute 'tcd ' . dir
call nerdtree#echo("Tab's CWD is now: " . getcwd()) call nerdtree#echo("Tab's CWD is now: " . getcwd())
else else
@ -201,7 +201,7 @@ function! s:Path.copy(dest)
let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars()) let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars())
let success = system(cmd) let success = system(cmd)
if v:shell_error != 0 if v:shell_error !=# 0
throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'"
endif endif
endfunction endfunction
@ -258,7 +258,7 @@ function! s:Path.delete()
let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1}) let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1})
let success = system(cmd) let success = system(cmd)
if v:shell_error != 0 if v:shell_error !=# 0
throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'" throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'"
endif endif
else else
@ -269,7 +269,7 @@ function! s:Path.delete()
let success = delete(self.str()) let success = delete(self.str())
endif endif
if success != 0 if success !=# 0
throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'" throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'"
endif endif
endif endif
@ -303,7 +303,7 @@ endfunction
" If running windows, cache the drive letter for this path " If running windows, cache the drive letter for this path
function! s:Path.extractDriveLetter(fullpath) function! s:Path.extractDriveLetter(fullpath)
if nerdtree#runningWindows() if nerdtree#runningWindows()
if a:fullpath =~ '^\(\\\\\|\/\/\)' if a:fullpath =~# '^\(\\\\\|\/\/\)'
"For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share
let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '')
let self.drive = substitute(self.drive, '/', '\', 'g') let self.drive = substitute(self.drive, '/', '\', 'g')
@ -402,7 +402,7 @@ function! s:Path._splitChunks(path)
let i = 0 let i = 0
while i < len(chunks) while i < len(chunks)
"convert number literals to numbers "convert number literals to numbers
if match(chunks[i], '^\d\+$') == 0 if match(chunks[i], '^\d\+$') ==# 0
let chunks[i] = str2nr(chunks[i]) let chunks[i] = str2nr(chunks[i])
endif endif
let i = i + 1 let i = i + 1
@ -418,16 +418,16 @@ function! s:Path.getSortKey()
let metadata = [] let metadata = []
for tag in g:NERDTreeSortOrder for tag in g:NERDTreeSortOrder
if tag =~? '\[\[-\?timestamp\]\]' if tag =~? '\[\[-\?timestamp\]\]'
let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~ '-' ? -1 : 1)] let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~# '-' ? -1 : 1)]
elseif tag =~? '\[\[-\?size\]\]' elseif tag =~? '\[\[-\?size\]\]'
let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~ '-' ? -1 : 1)] let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~# '-' ? -1 : 1)]
elseif tag =~? '\[\[extension\]\]' elseif tag =~? '\[\[extension\]\]'
let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$')
let metadata += [self.isDirectory ? '' : (extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)] let metadata += [self.isDirectory ? '' : (extension ==# '' ? nr2char(str2nr('0x10ffff',16)) : extension)]
endif endif
endfor endfor
if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]' if g:NERDTreeSortOrder[0] =~# '\[\[.*\]\]'
" Apply tags' sorting first if specified first. " Apply tags' sorting first if specified first.
let self._sortKey = metadata + [self.getSortOrderIndex()] let self._sortKey = metadata + [self.getSortOrderIndex()]
else else
@ -501,7 +501,7 @@ function! s:Path.ignore(nerdtree)
endfor endfor
for Callback in g:NERDTree.PathFilters() for Callback in g:NERDTree.PathFilters()
let Callback = type(Callback) == type(function('tr')) ? Callback : function(Callback) let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback)
if Callback({'path': self, 'nerdtree': a:nerdtree}) if Callback({'path': self, 'nerdtree': a:nerdtree})
return 1 return 1
endif endif
@ -524,12 +524,12 @@ endfunction
" returns true if this path matches the given ignore pattern " returns true if this path matches the given ignore pattern
function! s:Path._ignorePatternMatches(pattern) function! s:Path._ignorePatternMatches(pattern)
let pat = a:pattern let pat = a:pattern
if strpart(pat,len(pat)-7) == '[[dir]]' if strpart(pat,len(pat)-7) ==# '[[dir]]'
if !self.isDirectory if !self.isDirectory
return 0 return 0
endif endif
let pat = strpart(pat,0, len(pat)-7) let pat = strpart(pat,0, len(pat)-7)
elseif strpart(pat,len(pat)-8) == '[[file]]' elseif strpart(pat,len(pat)-8) ==# '[[file]]'
if self.isDirectory if self.isDirectory
return 0 return 0
endif endif
@ -550,19 +550,19 @@ function! s:Path.isAncestor(path)
let this = self.str() let this = self.str()
let that = a:path.str() let that = a:path.str()
return stridx(that, this) == 0 return stridx(that, this) ==# 0
endfunction endfunction
" FUNCTION: Path.isUnder(path) {{{1 " FUNCTION: Path.isUnder(path) {{{1
" return 1 if this path is somewhere under the given path in the filesystem. " return 1 if this path is somewhere under the given path in the filesystem.
function! s:Path.isUnder(path) function! s:Path.isUnder(path)
if a:path.isDirectory == 0 if a:path.isDirectory ==# 0
return 0 return 0
endif endif
let this = self.str() let this = self.str()
let that = a:path.str() let that = a:path.str()
return stridx(this, that . s:Path.Slash()) == 0 return stridx(this, that . s:Path.Slash()) ==# 0
endfunction endfunction
" FUNCTION: Path.JoinPathStrings(...) {{{1 " FUNCTION: Path.JoinPathStrings(...) {{{1
@ -665,7 +665,7 @@ function! s:Path.readInfoFromDisk(fullpath)
let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent
"if the last part of the path is a symlink then flag it as such "if the last part of the path is a symlink then flag it as such
let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath) let self.isSymLink = (s:Path.Resolve(hardPath) !=# hardPath)
if self.isSymLink if self.isSymLink
let self.symLinkDest = s:Path.Resolve(fullpath) let self.symLinkDest = s:Path.Resolve(fullpath)
@ -706,7 +706,7 @@ function! s:Path.rename(newPath)
call s:Path.createParentDirectories(a:newPath) call s:Path.createParentDirectories(a:newPath)
let success = rename(self.str(), a:newPath) let success = rename(self.str(), a:newPath)
if success != 0 if success !=# 0
throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath
endif endif
call self.readInfoFromDisk(a:newPath) call self.readInfoFromDisk(a:newPath)
@ -779,7 +779,7 @@ endfunction
" FUNCTION: Path._strForUI() {{{1 " FUNCTION: Path._strForUI() {{{1
function! s:Path._strForUI() function! s:Path._strForUI()
let toReturn = '/' . join(self.pathSegments, '/') let toReturn = '/' . join(self.pathSegments, '/')
if self.isDirectory && toReturn != '/' if self.isDirectory && toReturn !=# '/'
let toReturn = toReturn . '/' let toReturn = toReturn . '/'
endif endif
return toReturn return toReturn
@ -802,7 +802,7 @@ function! s:Path._strForEdit()
" On Windows, the drive letter may be removed by "fnamemodify()". Add it " On Windows, the drive letter may be removed by "fnamemodify()". Add it
" back, if necessary. " back, if necessary.
if nerdtree#runningWindows() && l:result[0] == s:Path.Slash() if nerdtree#runningWindows() && l:result[0] ==# s:Path.Slash()
let l:result = self.drive . l:result let l:result = self.drive . l:result
endif endif

View File

@ -14,7 +14,7 @@ let g:NERDTreeDirNode = s:TreeDirNode
" Class method that returns the highest cached ancestor of the current root. " Class method that returns the highest cached ancestor of the current root.
function! s:TreeDirNode.AbsoluteTreeRoot() function! s:TreeDirNode.AbsoluteTreeRoot()
let currentNode = b:NERDTree.root let currentNode = b:NERDTree.root
while currentNode.parent != {} while currentNode.parent !=# {}
let currentNode = currentNode.parent let currentNode = currentNode.parent
endwhile endwhile
return currentNode return currentNode
@ -100,7 +100,7 @@ function! s:TreeDirNode.displayString()
let l:cascade = self.getCascade() let l:cascade = self.getCascade()
for l:dirNode in l:cascade for l:dirNode in l:cascade
let l:next = l:dirNode.path.displayString() let l:next = l:dirNode.path.displayString()
let l:label .= l:label == '' ? l:next : substitute(l:next,'^.','','') let l:label .= l:label ==# '' ? l:next : substitute(l:next,'^.','','')
endfor endfor
" Select the appropriate open/closed status indicator symbol. " Select the appropriate open/closed status indicator symbol.
@ -133,7 +133,7 @@ function! s:TreeDirNode.findNode(path)
if self.path.isDirectory if self.path.isDirectory
for i in self.children for i in self.children
let retVal = i.findNode(a:path) let retVal = i.findNode(a:path)
if retVal != {} if retVal !=# {}
return retVal return retVal
endif endif
endfor endfor
@ -169,7 +169,7 @@ function! s:TreeDirNode.getCascadeRoot()
while !empty(l:parent) && !l:parent.isRoot() while !empty(l:parent) && !l:parent.isRoot()
if index(l:parent.getCascade(), self) == -1 if index(l:parent.getCascade(), self) ==# -1
break break
endif endif
@ -258,7 +258,7 @@ endfunction
" Return a list of all child nodes from 'self.children' that are of type " Return a list of all child nodes from 'self.children' that are of type
" TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. " TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git.
function! s:TreeDirNode.getDirChildren() function! s:TreeDirNode.getDirChildren()
return filter(copy(self.children), 'v:val.path.isDirectory == 1') return filter(copy(self.children), 'v:val.path.isDirectory ==# 1')
endfunction endfunction
" FUNCTION: TreeDirNode._glob(pattern, all) {{{1 " FUNCTION: TreeDirNode._glob(pattern, all) {{{1
@ -278,13 +278,13 @@ function! s:TreeDirNode._glob(pattern, all)
" Construct a path specification such that globpath() will return " Construct a path specification such that globpath() will return
" relative pathnames, if possible. " relative pathnames, if possible.
if self.path.str() == getcwd() if self.path.str() ==# getcwd()
let l:pathSpec = ',' let l:pathSpec = ','
else else
let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',')
" On Windows, the drive letter may be removed by fnamemodify(). " On Windows, the drive letter may be removed by fnamemodify().
if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() if nerdtree#runningWindows() && l:pathSpec[0] ==# g:NERDTreePath.Slash()
let l:pathSpec = self.path.drive . l:pathSpec let l:pathSpec = self.path.drive . l:pathSpec
endif endif
endif endif
@ -293,11 +293,11 @@ function! s:TreeDirNode._glob(pattern, all)
" See ':h version7.txt' and ':h version8.txt' for details on the " See ':h version7.txt' and ':h version8.txt' for details on the
" development of the glob() and globpath() functions. " development of the glob() and globpath() functions.
if v:version > 704 || (v:version == 704 && has('patch654')) if v:version > 704 || (v:version ==# 704 && has('patch654'))
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0)
elseif v:version == 704 && has('patch279') elseif v:version ==# 704 && has('patch279')
let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1)
elseif v:version > 702 || (v:version == 702 && has('patch051')) elseif v:version > 702 || (v:version ==# 702 && has('patch051'))
let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore)
let l:globList = split(l:globString, "\n") let l:globList = split(l:globString, "\n")
else else
@ -315,13 +315,13 @@ function! s:TreeDirNode._glob(pattern, all)
" If l:file has a trailing slash, then its :tail will be ''. Use " If l:file has a trailing slash, then its :tail will be ''. Use
" :h to drop the slash and the empty string after it; then use :t " :h to drop the slash and the empty string after it; then use :t
" to get the directory name. " to get the directory name.
if l:tail == '' if l:tail ==# ''
let l:tail = fnamemodify(l:file, ':h:t') let l:tail = fnamemodify(l:file, ':h:t')
endif endif
if l:tail == '.' || l:tail == '..' if l:tail ==# '.' || l:tail ==# '..'
call add(l:toRemove, l:file) call add(l:toRemove, l:file)
if len(l:toRemove) == 2 if len(l:toRemove) ==# 2
break break
endif endif
endif endif
@ -341,7 +341,7 @@ endfunction
unlet s:TreeDirNode.GetSelected unlet s:TreeDirNode.GetSelected
function! s:TreeDirNode.GetSelected() function! s:TreeDirNode.GetSelected()
let currentDir = g:NERDTreeFileNode.GetSelected() let currentDir = g:NERDTreeFileNode.GetSelected()
if currentDir != {} && !currentDir.isRoot() if currentDir !=# {} && !currentDir.isRoot()
if currentDir.path.isDirectory ==# 0 if currentDir.path.isDirectory ==# 0
let currentDir = currentDir.parent let currentDir = currentDir.parent
endif endif
@ -373,7 +373,7 @@ endfunction
" FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 " FUNCTION: TreeDirNode.hasVisibleChildren() {{{1
" returns 1 if this node has any childre, 0 otherwise.. " returns 1 if this node has any childre, 0 otherwise..
function! s:TreeDirNode.hasVisibleChildren() function! s:TreeDirNode.hasVisibleChildren()
return self.getVisibleChildCount() != 0 return self.getVisibleChildCount() !=# 0
endfunction endfunction
" FUNCTION: TreeDirNode.isCascadable() {{{1 " FUNCTION: TreeDirNode.isCascadable() {{{1
@ -383,7 +383,7 @@ endfunction
" 2. If the parent is a symlink or is bookmarked, you end up with unparsable " 2. If the parent is a symlink or is bookmarked, you end up with unparsable
" text, and NERDTree cannot get the path of any child node. " text, and NERDTree cannot get the path of any child node.
function! s:TreeDirNode.isCascadable() function! s:TreeDirNode.isCascadable()
if g:NERDTreeCascadeSingleChildDir == 0 if g:NERDTreeCascadeSingleChildDir ==# 0
return 0 return 0
endif endif
@ -398,7 +398,7 @@ function! s:TreeDirNode.isCascadable()
endfor endfor
let c = self.getVisibleChildren() let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory return len(c) ==# 1 && c[0].path.isDirectory
endfunction endfunction
" FUNCTION: TreeDirNode._initChildren() {{{1 " FUNCTION: TreeDirNode._initChildren() {{{1
@ -447,7 +447,7 @@ endfunction
" path: dir that the node represents " path: dir that the node represents
" nerdtree: the tree the node belongs to " nerdtree: the tree the node belongs to
function! s:TreeDirNode.New(path, nerdtree) function! s:TreeDirNode.New(path, nerdtree)
if a:path.isDirectory != 1 if a:path.isDirectory !=# 1
throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.' throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.'
endif endif
@ -510,7 +510,7 @@ function! s:TreeDirNode.openAlong(...)
while node.path.isDirectory while node.path.isDirectory
call node.open(opts) call node.open(opts)
let level += 1 let level += 1
if node.getVisibleChildCount() == 1 if node.getVisibleChildCount() ==# 1
let node = node.getChildByIndex(0, 1) let node = node.getChildByIndex(0, 1)
else else
break break
@ -567,7 +567,7 @@ function! s:TreeDirNode.refresh()
"create a new path and see if it exists in this nodes children "create a new path and see if it exists in this nodes children
let path = g:NERDTreePath.New(i) let path = g:NERDTreePath.New(i)
let newNode = self.getChild(path) let newNode = self.getChild(path)
if newNode != {} if newNode !=# {}
call newNode.refresh() call newNode.refresh()
call add(newChildNodes, newNode) call add(newChildNodes, newNode)
@ -622,7 +622,7 @@ function! s:TreeDirNode.reveal(path, ...)
if self.path.equals(a:path.getParent()) if self.path.equals(a:path.getParent())
let n = self.findNode(a:path) let n = self.findNode(a:path)
" We may be looking for a newly-saved file that isn't in the tree yet. " We may be looking for a newly-saved file that isn't in the tree yet.
if n == {} if n ==# {}
call self.refresh() call self.refresh()
let n = self.findNode(a:path) let n = self.findNode(a:path)
endif endif
@ -676,7 +676,7 @@ function! s:TreeDirNode.toggleOpen(...)
if self.isOpen ==# 1 if self.isOpen ==# 1
call self.close() call self.close()
else else
if g:NERDTreeCascadeOpenSingleChildDir == 0 if g:NERDTreeCascadeOpenSingleChildDir ==# 0
call self.open(opts) call self.open(opts)
else else
call self.openAlong(opts) call self.openAlong(opts)

View File

@ -157,7 +157,7 @@ function! s:UI.getPath(ln)
let rootLine = self.getRootLineNum() let rootLine = self.getRootLineNum()
if a:ln == rootLine if a:ln ==# rootLine
return self.nerdtree.root.path return self.nerdtree.root.path
endif endif
@ -182,7 +182,7 @@ function! s:UI.getPath(ln)
let curLineStripped = self._stripMarkup(curLine) let curLineStripped = self._stripMarkup(curLine)
" have we reached the top of the tree? " have we reached the top of the tree?
if lnum == rootLine if lnum ==# rootLine
let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir
break break
endif endif
@ -219,7 +219,7 @@ function! s:UI.getLineNum(node)
let l:currentLine = getline(l:lineNumber) let l:currentLine = getline(l:lineNumber)
let l:indentLevel = self._indentLevelFor(l:currentLine) let l:indentLevel = self._indentLevelFor(l:currentLine)
if l:indentLevel != l:currentPathComponent if l:indentLevel !=# l:currentPathComponent
continue continue
endif endif
@ -229,7 +229,7 @@ function! s:UI.getLineNum(node)
" Directories: If the current path 'starts with' the full path, then " Directories: If the current path 'starts with' the full path, then
" either the paths are equal or the line is a cascade containing the " either the paths are equal or the line is a cascade containing the
" full path. " full path.
if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0 if l:fullPath[-1:] ==# '/' && stridx(l:currentPath, l:fullPath) ==# 0
return l:lineNumber return l:lineNumber
endif endif
@ -240,7 +240,7 @@ function! s:UI.getLineNum(node)
" Otherwise: If the full path starts with the current path and the " Otherwise: If the full path starts with the current path and the
" current path is a directory, we add a new path component. " current path is a directory, we add a new path component.
if stridx(l:fullPath, l:currentPath) == 0 && l:currentPath[-1:] == '/' if stridx(l:fullPath, l:currentPath) ==# 0 && l:currentPath[-1:] ==# '/'
let l:currentLine = substitute(l:currentLine, '/\s*$', '', '') let l:currentLine = substitute(l:currentLine, '/\s*$', '', '')
call add(l:pathComponents, l:currentLine) call add(l:pathComponents, l:currentLine)
let l:currentPathComponent += 1 let l:currentPathComponent += 1
@ -296,7 +296,7 @@ endfunction
" FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 " FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
function! s:UI.isIgnoreFilterEnabled() function! s:UI.isIgnoreFilterEnabled()
return self._ignoreEnabled == 1 return self._ignoreEnabled ==# 1
endfunction endfunction
" FUNCTION: s:UI.isMinimal() {{{1 " FUNCTION: s:UI.isMinimal() {{{1
@ -317,7 +317,7 @@ function! s:UI._renderBookmarks()
call cursor(line('.')+1, col('.')) call cursor(line('.')+1, col('.'))
endif endif
if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 if g:NERDTreeBookmarksSort ==# 1 || g:NERDTreeBookmarksSort ==# 2
call g:NERDTreeBookmark.SortBookmarksList() call g:NERDTreeBookmark.SortBookmarksList()
endif endif
@ -443,13 +443,13 @@ function! s:UI.renderViewSavingPosition()
" go up the tree till we find a node that will be visible or till we run " go up the tree till we find a node that will be visible or till we run
" out of nodes " out of nodes
while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() while currentNode !=# {} && !currentNode.isVisible() && !currentNode.isRoot()
let currentNode = currentNode.parent let currentNode = currentNode.parent
endwhile endwhile
call self.render() call self.render()
if currentNode != {} if currentNode !=# {}
call currentNode.putCursorHere(0, 0) call currentNode.putCursorHere(0, 0)
endif endif
endfunction endfunction

View File

@ -32,7 +32,7 @@ function! NERDTreeExecFile()
let cmd = treenode.path.str({'escape': 1}) let cmd = treenode.path.str({'escape': 1})
let cmd = input(':!', cmd . ' ') let cmd = input(':!', cmd . ' ')
if cmd != '' if cmd !=# ''
exec ':!' . cmd exec ':!' . cmd
else else
echo 'Aborted' echo 'Aborted'

View File

@ -51,27 +51,27 @@ endif
"Args: "Args:
"action: the action that is being performed, e.g. 'delete' "action: the action that is being performed, e.g. 'delete'
function! s:inputPrompt(action) function! s:inputPrompt(action)
if a:action == 'add' if a:action ==# 'add'
let title = 'Add a childnode' let title = 'Add a childnode'
let info = "Enter the dir/file name to be created. Dirs end with a '/'" let info = "Enter the dir/file name to be created. Dirs end with a '/'"
let minimal = 'Add node:' let minimal = 'Add node:'
elseif a:action == 'copy' elseif a:action ==# 'copy'
let title = 'Copy the current node' let title = 'Copy the current node'
let info = 'Enter the new path to copy the node to:' let info = 'Enter the new path to copy the node to:'
let minimal = 'Copy to:' let minimal = 'Copy to:'
elseif a:action == 'delete' elseif a:action ==# 'delete'
let title = 'Delete the current node' let title = 'Delete the current node'
let info = 'Are you sure you wish to delete the node:' let info = 'Are you sure you wish to delete the node:'
let minimal = 'Delete?' let minimal = 'Delete?'
elseif a:action == 'deleteNonEmpty' elseif a:action ==# 'deleteNonEmpty'
let title = 'Delete the current node' let title = 'Delete the current node'
let info = "STOP! Directory is not empty! To delete, type 'yes'" let info = "STOP! Directory is not empty! To delete, type 'yes'"
let minimal = 'Delete directory?' let minimal = 'Delete directory?'
elseif a:action == 'move' elseif a:action ==# 'move'
let title = 'Rename the current node' let title = 'Rename the current node'
let info = 'Enter the new path for the node:' let info = 'Enter the new path for the node:'
let minimal = 'Move to:' let minimal = 'Move to:'
@ -114,9 +114,9 @@ function! s:promptToDelBuffer(bufnum, msg)
let l:listedBufferCount = 0 let l:listedBufferCount = 0
endif endif
if l:listedBufferCount > 1 if l:listedBufferCount > 1
call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':bnext! ' | endif", 1) call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':bnext! ' | endif", 1)
else else
call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':enew! ' | endif", 1) call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':enew! ' | endif", 1)
endif endif
call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec('tabnext ' . s:originalTabNumber, 1)
call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1)
@ -146,7 +146,7 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory)
" display a buffer for a new filename. " display a buffer for a new filename.
let s:originalTabNumber = tabpagenr() let s:originalTabNumber = tabpagenr()
let s:originalWindowNumber = winnr() let s:originalWindowNumber = winnr()
call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1)
call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec('tabnext ' . s:originalTabNumber, 1)
call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1)
" 3. We don't need a previous buffer anymore " 3. We don't need a previous buffer anymore
@ -330,7 +330,7 @@ function! NERDTreeCopyNode()
let prompt = s:inputPrompt('copy') let prompt = s:inputPrompt('copy')
let newNodePath = input(prompt, currentNode.path.str(), 'file') let newNodePath = input(prompt, currentNode.path.str(), 'file')
if newNodePath != '' if newNodePath !=# ''
"strip trailing slash "strip trailing slash
let newNodePath = substitute(newNodePath, '\/$', '', '') let newNodePath = substitute(newNodePath, '\/$', '', '')
@ -369,7 +369,7 @@ endfunction
function! NERDTreeCopyPath() function! NERDTreeCopyPath()
let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str()
if has('clipboard') if has('clipboard')
if &clipboard == 'unnamedplus' if &clipboard ==# 'unnamedplus'
let @+ = l:nodePath let @+ = l:nodePath
else else
let @* = l:nodePath let @* = l:nodePath
@ -383,7 +383,7 @@ endfunction
" FUNCTION: NERDTreeQuickLook() {{{1 " FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook() function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected() let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {} if treenode !=# {}
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
endif endif
endfunction endfunction
@ -391,7 +391,7 @@ endfunction
" FUNCTION: NERDTreeRevealInFinder() {{{1 " FUNCTION: NERDTreeRevealInFinder() {{{1
function! NERDTreeRevealInFinder() function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected() let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {} if treenode !=# {}
call system("open -R '" . treenode.path.str() . "'") call system("open -R '" . treenode.path.str() . "'")
endif endif
endfunction endfunction
@ -399,7 +399,7 @@ endfunction
" FUNCTION: NERDTreeExecuteFile() {{{1 " FUNCTION: NERDTreeExecuteFile() {{{1
function! NERDTreeExecuteFile() function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected() let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {} if treenode !=# {}
call system("open '" . treenode.path.str() . "'") call system("open '" . treenode.path.str() . "'")
endif endif
endfunction endfunction
@ -408,7 +408,7 @@ endfunction
function! NERDTreeRevealFileLinux() function! NERDTreeRevealFileLinux()
let treenode = g:NERDTreeFileNode.GetSelected() let treenode = g:NERDTreeFileNode.GetSelected()
let parentnode = treenode.parent let parentnode = treenode.parent
if parentnode != {} if parentnode !=# {}
call system("xdg-open '" . parentnode.path.str() . "' &") call system("xdg-open '" . parentnode.path.str() . "' &")
endif endif
endfunction endfunction
@ -416,7 +416,7 @@ endfunction
" FUNCTION: NERDTreeExecuteFileLinux() {{{1 " FUNCTION: NERDTreeExecuteFileLinux() {{{1
function! NERDTreeExecuteFileLinux() function! NERDTreeExecuteFileLinux()
let treenode = g:NERDTreeFileNode.GetSelected() let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {} if treenode !=# {}
call system("xdg-open '" . treenode.path.str() . "' &") call system("xdg-open '" . treenode.path.str() . "' &")
endif endif
endfunction endfunction

View File

@ -34,7 +34,7 @@ endfunction
function! s:FindParentVCSRoot(path) function! s:FindParentVCSRoot(path)
let l:path = a:path let l:path = a:path
while !empty(l:path) && while !empty(l:path) &&
\ l:path._str() !~ '^\(\a:\\\|\/\)$' && \ l:path._str() !~# '^\(\a:\\\|\/\)$' &&
\ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.git') &&
\ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.svn') &&
\ !isdirectory(l:path._str() . '/.hg') && \ !isdirectory(l:path._str() . '/.hg') &&
@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path)
\ !isdirectory(l:path._str() . '/_darcs') \ !isdirectory(l:path._str() . '/_darcs')
let l:path = l:path.getParent() let l:path = l:path.getParent()
endwhile endwhile
return (empty(l:path) || l:path._str() =~ '^\(\a:\\\|\/\)$') ? a:path : l:path return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path
endfunction endfunction

View File

@ -91,7 +91,7 @@ call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO')
if has('conceal') if has('conceal')
call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") call s:initVariable('g:NERDTreeNodeDelimiter', "\x07")
elseif (g:NERDTreeDirArrowExpandable == "\u00a0" || g:NERDTreeDirArrowCollapsible == "\u00a0") elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0")
call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7")
else else
call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0")
@ -184,7 +184,7 @@ if g:NERDTreeHijackNetrw
augroup END augroup END
endif endif
if g:NERDTreeChDirMode == 3 if g:NERDTreeChDirMode ==# 3
augroup NERDTreeChDirOnTabSwitch augroup NERDTreeChDirOnTabSwitch
autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif
augroup END augroup END