use ==# always instead of ==

this is because of vims fucking stupid functionality where ignorecase
changes the way == behaves. It was causing bugs when the user had
ignorecase set.
This commit is contained in:
Martin Grenfell
2009-01-24 00:06:41 +13:00
parent 8164fa09d3
commit 992c9f24eb

View File

@@ -181,7 +181,7 @@ let s:Bookmark = {}
" with the same name, just update the path for that bookmark " with the same name, just update the path for that bookmark
function! s:Bookmark.AddBookmark(name, path) function! s:Bookmark.AddBookmark(name, path)
for i in s:Bookmark.Bookmarks() for i in s:Bookmark.Bookmarks()
if i.name == a:name if i.name ==# a:name
let i.path = a:path let i.path = a:path
return return
endif endif
@@ -214,7 +214,7 @@ endfunction
" bookmark is found " bookmark is found
function! s:Bookmark.BookmarkFor(name) function! s:Bookmark.BookmarkFor(name)
for i in s:Bookmark.Bookmarks() for i in s:Bookmark.Bookmarks()
if i.name == a:name if i.name ==# a:name
return i return i
endif endif
endfor endfor
@@ -492,7 +492,7 @@ endfunction
"FUNCTION: TreeFileNode.renderToString {{{3 "FUNCTION: TreeFileNode.renderToString {{{3
"returns a string representation for this tree to be rendered in the view "returns a string representation for this tree to be rendered in the view
function! s:TreeFileNode.renderToString() function! s:TreeFileNode.renderToString()
return self._renderToString(0, 0, [], self.getChildCount() == 1) return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
endfunction endfunction
@@ -505,14 +505,14 @@ endfunction
"isLastChild:true if this curNode is the last child of its parent "isLastChild:true if this curNode is the last child of its parent
function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
let output = "" let output = ""
if a:drawText == 1 if a:drawText ==# 1
let treeParts = '' let treeParts = ''
"get all the leading spaces and vertical tree parts for this line "get all the leading spaces and vertical tree parts for this line
if a:depth > 1 if a:depth > 1
for j in a:vertMap[0:-2] for j in a:vertMap[0:-2]
if j == 1 if j ==# 1
let treeParts = treeParts . '| ' let treeParts = treeParts . '| '
else else
let treeParts = treeParts . ' ' let treeParts = treeParts . ' '
@@ -546,7 +546,7 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
endif endif
"if the node is an open dir, draw its children "if the node is an open dir, draw its children
if self.path.isDirectory == 1 && self.isOpen == 1 if self.path.isDirectory ==# 1 && self.isOpen ==# 1
let childNodesToDraw = self.getVisibleChildren() let childNodesToDraw = self.getVisibleChildren()
if len(childNodesToDraw) > 0 if len(childNodesToDraw) > 0
@@ -577,7 +577,7 @@ endfunction
"Args: "Args:
"treenode: the other treenode to compare to "treenode: the other treenode to compare to
function! s:TreeFileNode.equals(treenode) function! s:TreeFileNode.equals(treenode)
return self.path.str(1) == a:treenode.path.str(1) return self.path.str(1) ==# a:treenode.path.str(1)
endfunction endfunction
"FUNCTION: TreeFileNode.findNode(path) {{{3 "FUNCTION: TreeFileNode.findNode(path) {{{3
@@ -635,7 +635,7 @@ function! s:TreeFileNode.findSibling(direction)
if siblingIndx != -1 if siblingIndx != -1
"move a long to the next potential sibling node "move a long to the next potential sibling node
let siblingIndx = a:direction == 1 ? siblingIndx+1 : siblingIndx-1 let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
"keep moving along to the next sibling till we find one that is valid "keep moving along to the next sibling till we find one that is valid
let numSiblings = self.parent.getChildCount() let numSiblings = self.parent.getChildCount()
@@ -643,12 +643,12 @@ function! s:TreeFileNode.findSibling(direction)
"if the next node is not an ignored node (i.e. wont show up in the "if the next node is not an ignored node (i.e. wont show up in the
"view) then return it "view) then return it
if self.parent.children[siblingIndx].path.ignore() == 0 if self.parent.children[siblingIndx].path.ignore() ==# 0
return self.parent.children[siblingIndx] return self.parent.children[siblingIndx]
endif endif
"go to next node "go to next node
let siblingIndx = a:direction == 1 ? siblingIndx+1 : siblingIndx-1 let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
endwhile endwhile
endif endif
endif endif
@@ -678,24 +678,24 @@ function! s:TreeFileNode.getLineNum()
while lnum > 0 while lnum > 0
let lnum = lnum + 1 let lnum = lnum + 1
"have we reached the bottom of the tree? "have we reached the bottom of the tree?
if lnum == totalLines+1 if lnum ==# totalLines+1
return -1 return -1
endif endif
let curLine = getline(lnum) let curLine = getline(lnum)
let indent = s:indentLevelFor(curLine) let indent = s:indentLevelFor(curLine)
if indent == curPathComponent if indent ==# curPathComponent
let curLine = s:stripMarkupFromLine(curLine, 1) let curLine = s:stripMarkupFromLine(curLine, 1)
let curPath = join(pathcomponents, '/') . '/' . curLine let curPath = join(pathcomponents, '/') . '/' . curLine
if stridx(fullpath, curPath, 0) == 0 if stridx(fullpath, curPath, 0) ==# 0
if fullpath == curPath || strpart(fullpath, len(curPath)-1,1) == '/' if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
let curLine = substitute(curLine, '/ *$', '', '') let curLine = substitute(curLine, '/ *$', '', '')
call add(pathcomponents, curLine) call add(pathcomponents, curLine)
let curPathComponent = curPathComponent + 1 let curPathComponent = curPathComponent + 1
if fullpath == curPath if fullpath ==# curPath
return lnum return lnum
endif endif
endif endif
@@ -720,7 +720,7 @@ endfunction
function! s:TreeFileNode.GetSelected() function! s:TreeFileNode.GetSelected()
try try
let path = s:getPath(line(".")) let path = s:getPath(line("."))
if path == {} if path ==# {}
return {} return {}
endif endif
return b:NERDTreeRoot.findNode(path) return b:NERDTreeRoot.findNode(path)
@@ -757,7 +757,7 @@ function! s:TreeFileNode.makeRoot()
call b:NERDTreeRoot.open() call b:NERDTreeRoot.open()
"change dir to the dir of the new root if instructed to "change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode == 2 if g:NERDTreeChDirMode ==# 2
exec "cd " . b:NERDTreeRoot.path.strForEditCmd() exec "cd " . b:NERDTreeRoot.path.strForEditCmd()
endif endif
endfunction endfunction
@@ -785,7 +785,7 @@ endfunction
"ARGS: "ARGS:
"treenode: file node to open "treenode: file node to open
function! s:TreeFileNode.open() function! s:TreeFileNode.open()
if b:NERDTreeType == "secondary" if b:NERDTreeType ==# "secondary"
exec 'edit ' . self.path.strForEditCmd() exec 'edit ' . self.path.strForEditCmd()
return return
endif endif
@@ -796,7 +796,7 @@ function! s:TreeFileNode.open()
call s:exec(winnr . "wincmd w") call s:exec(winnr . "wincmd w")
else else
if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() == -1 if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() ==# -1
call self.openSplit() call self.openSplit()
else else
try try
@@ -819,7 +819,7 @@ endfunction
"Open this node in a new window "Open this node in a new window
function! s:TreeFileNode.openSplit() function! s:TreeFileNode.openSplit()
if b:NERDTreeType == "secondary" if b:NERDTreeType ==# "secondary"
exec "split " . self.path.strForEditCmd() exec "split " . self.path.strForEditCmd()
return return
endif endif
@@ -837,15 +837,15 @@ function! s:TreeFileNode.openSplit()
" 'right' and 'below' will be set to the settings needed for " 'right' and 'below' will be set to the settings needed for
" splitbelow and splitright IF the explorer is the only window. " splitbelow and splitright IF the explorer is the only window.
" "
let there= g:NERDTreeWinPos == "left" ? "wincmd h" : "wincmd l" let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l"
let back = g:NERDTreeWinPos == "left" ? "wincmd l" : "wincmd h" let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h"
let right= g:NERDTreeWinPos == "left" let right= g:NERDTreeWinPos ==# "left"
let below=0 let below=0
" Attempt to go to adjacent window " Attempt to go to adjacent window
call s:exec(back) call s:exec(back)
let onlyOneWin = (winnr("$") == 1) let onlyOneWin = (winnr("$") ==# 1)
" If no adjacent window, set splitright and splitbelow appropriately " If no adjacent window, set splitright and splitbelow appropriately
if onlyOneWin if onlyOneWin
@@ -884,13 +884,13 @@ endfunction
"FUNCTION: TreeFileNode.openVSplit() {{{3 "FUNCTION: TreeFileNode.openVSplit() {{{3
"Open this node in a new vertical window "Open this node in a new vertical window
function! s:TreeFileNode.openVSplit() function! s:TreeFileNode.openVSplit()
if b:NERDTreeType == "secondary" if b:NERDTreeType ==# "secondary"
exec "vnew " . self.path.strForEditCmd() exec "vnew " . self.path.strForEditCmd()
return return
endif endif
let winwidth = winwidth(".") let winwidth = winwidth(".")
if winnr("$")==1 if winnr("$")==#1
let winwidth = g:NERDTreeWinSize let winwidth = g:NERDTreeWinSize
endif endif
@@ -919,7 +919,7 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
else else
if a:recurseUpward if a:recurseUpward
let node = self let node = self
while node != {} && node.getLineNum() == -1 while node != {} && node.getLineNum() ==# -1
let node = node.parent let node = node.parent
call node.open() call node.open()
endwhile endwhile
@@ -1032,7 +1032,7 @@ function! s:TreeDirNode.findNode(path)
if a:path.equals(self.path) if a:path.equals(self.path)
return self return self
endif endif
if stridx(a:path.str(1), self.path.str(1), 0) == -1 if stridx(a:path.str(1), self.path.str(1), 0) ==# -1
return {} return {}
endif endif
@@ -1061,12 +1061,12 @@ endfunction
"Args: "Args:
"path: a path object "path: a path object
function! s:TreeDirNode.getChild(path) function! s:TreeDirNode.getChild(path)
if stridx(a:path.str(1), self.path.str(1), 0) == -1 if stridx(a:path.str(1), self.path.str(1), 0) ==# -1
return {} return {}
endif endif
let index = self.getChildIndex(a:path) let index = self.getChildIndex(a:path)
if index == -1 if index ==# -1
return {} return {}
else else
return self.children[index] return self.children[index]
@@ -1097,7 +1097,7 @@ endfunction
"Args: "Args:
"path: a path object "path: a path object
function! s:TreeDirNode.getChildIndex(path) function! s:TreeDirNode.getChildIndex(path)
if stridx(a:path.str(1), self.path.str(1), 0) == -1 if stridx(a:path.str(1), self.path.str(1), 0) ==# -1
return -1 return -1
endif endif
@@ -1108,9 +1108,9 @@ function! s:TreeDirNode.getChildIndex(path)
let mid = (a+z)/2 let mid = (a+z)/2
let diff = a:path.compareTo(self.children[mid].path) let diff = a:path.compareTo(self.children[mid].path)
if diff == -1 if diff ==# -1
let z = mid let z = mid
elseif diff == 1 elseif diff ==# 1
let a = mid+1 let a = mid+1
else else
return mid return mid
@@ -1126,7 +1126,7 @@ unlet s:TreeDirNode.GetSelected
function! s:TreeDirNode.GetSelected() function! s:TreeDirNode.GetSelected()
let currentDir = s:TreeFileNode.GetSelected() let currentDir = s:TreeFileNode.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
endif endif
@@ -1146,7 +1146,7 @@ endfunction
function! s:TreeDirNode.getVisibleChildren() function! s:TreeDirNode.getVisibleChildren()
let toReturn = [] let toReturn = []
for i in self.children for i in self.children
if i.path.ignore() == 0 if i.path.ignore() ==# 0
call add(toReturn, i) call add(toReturn, i)
endif endif
endfor endfor
@@ -1237,7 +1237,7 @@ endfunction
unlet s:TreeDirNode.open unlet s:TreeDirNode.open
function! s:TreeDirNode.open() function! s:TreeDirNode.open()
let self.isOpen = 1 let self.isOpen = 1
if self.children == [] if self.children ==# []
return self._initChildren(0) return self._initChildren(0)
else else
return 0 return 0
@@ -1250,7 +1250,7 @@ endfunction
function! s:TreeDirNode.openExplorer() function! s:TreeDirNode.openExplorer()
let oldwin = winnr() let oldwin = winnr()
call s:exec('wincmd p') call s:exec('wincmd p')
if oldwin == winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2) if oldwin ==# winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2)
call s:exec('wincmd p') call s:exec('wincmd p')
call self.openSplit() call self.openSplit()
else else
@@ -1275,14 +1275,14 @@ endfunction
"Args: "Args:
"forceOpen: 1 if this node should be opened regardless of file filters "forceOpen: 1 if this node should be opened regardless of file filters
function! s:TreeDirNode._openRecursively2(forceOpen) function! s:TreeDirNode._openRecursively2(forceOpen)
if self.path.ignore() == 0 || a:forceOpen if self.path.ignore() ==# 0 || a:forceOpen
let self.isOpen = 1 let self.isOpen = 1
if self.children == [] if self.children ==# []
call self._initChildren(1) call self._initChildren(1)
endif endif
for i in self.children for i in self.children
if i.path.isDirectory == 1 if i.path.isDirectory ==# 1
call i._openRecursively2(0) call i._openRecursively2(0)
endif endif
endfor endfor
@@ -1369,7 +1369,7 @@ endfunction
"FUNCTION: TreeDirNode.toggleOpen() {{{3 "FUNCTION: TreeDirNode.toggleOpen() {{{3
"Opens this directory if it is closed and vice versa "Opens this directory if it is closed and vice versa
function! s:TreeDirNode.toggleOpen() function! s:TreeDirNode.toggleOpen()
if self.isOpen == 1 if self.isOpen ==# 1
call self.close() call self.close()
else else
call self.open() call self.open()
@@ -1448,7 +1448,7 @@ endfunction
"FUNCTION: Path.changeToDir() {{{3 "FUNCTION: Path.changeToDir() {{{3
function! s:Path.changeToDir() function! s:Path.changeToDir()
let dir = self.strForCd() let dir = self.strForCd()
if self.isDirectory == 0 if self.isDirectory ==# 0
let dir = self.getPathTrunk().strForCd() let dir = self.getPathTrunk().strForCd()
endif endif
@@ -1475,7 +1475,7 @@ function! s:Path.compareTo(path)
let thatPath = a:path.getLastPathComponent(1) let thatPath = a:path.getLastPathComponent(1)
"if the paths are the same then clearly we return 0 "if the paths are the same then clearly we return 0
if thisPath == thatPath if thisPath ==# thatPath
return 0 return 0
endif endif
@@ -1710,11 +1710,11 @@ function! s:Path.ignore()
endif endif
"dont show hidden files unless instructed to "dont show hidden files unless instructed to
if b:NERDTreeShowHidden == 0 && lastPathComponent =~ '^\.' if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~ '^\.'
return 1 return 1
endif endif
if b:NERDTreeShowFiles == 0 && self.isDirectory == 0 if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0
return 1 return 1
endif endif
@@ -1738,7 +1738,7 @@ endfunction
"Args: "Args:
"path: the other path obj to compare this with "path: the other path obj to compare this with
function! s:Path.equals(path) function! s:Path.equals(path)
return self.str(0) == a:path.str(0) return self.str(0) ==# a:path.str(0)
endfunction endfunction
"FUNCTION: Path.New() {{{3 "FUNCTION: Path.New() {{{3
@@ -1762,7 +1762,7 @@ function! s:Path.readInfoFromDisk(fullpath)
let fullpath = s:Path.WinToUnixPath(a:fullpath) let fullpath = s:Path.WinToUnixPath(a:fullpath)
if getftype(fullpath) == "fifo" if getftype(fullpath) ==# "fifo"
throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath
endif endif
@@ -1773,7 +1773,7 @@ function! s:Path.readInfoFromDisk(fullpath)
let self.isDirectory = 1 let self.isDirectory = 1
elseif filereadable(a:fullpath) elseif filereadable(a:fullpath)
let self.isDirectory = 0 let self.isDirectory = 0
let self.isReadOnly = filewritable(a:fullpath) == 0 let self.isReadOnly = filewritable(a:fullpath) ==# 0
else else
throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath
endif endif
@@ -1817,7 +1817,7 @@ endfunction
" "
"Renames this node on the filesystem "Renames this node on the filesystem
function! s:Path.rename(newPath) function! s:Path.rename(newPath)
if a:newPath == '' if a:newPath ==# ''
throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
endif endif
@@ -1883,7 +1883,7 @@ endfunction
"Return: "Return:
"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:Path.strDisplay() function! s:Path.strDisplay()
if self.cachedDisplayString == "" if self.cachedDisplayString ==# ""
call self.cacheDisplayString() call self.cacheDisplayString()
endif endif
@@ -1906,11 +1906,11 @@ function! s:Path.strForEditCmd()
let cwd = cwd . s:os_slash let cwd = cwd . s:os_slash
"return a relative path if we can "return a relative path if we can
if stridx(p, cwd) == 0 if stridx(p, cwd) ==# 0
let p = strpart(p, strlen(cwd)) let p = strpart(p, strlen(cwd))
endif endif
if p == '' if p ==# ''
let p = '.' let p = '.'
endif endif
@@ -2008,7 +2008,7 @@ function! s:bufInWindows(bnum)
if bufnum < 0 if bufnum < 0
break break
endif endif
if bufnum == a:bnum if bufnum ==# a:bnum
let cnt = cnt + 1 let cnt = cnt + 1
endif endif
let winnum = winnum + 1 let winnum = winnum + 1
@@ -2053,7 +2053,7 @@ function! s:initNerdTree(name)
if s:Bookmark.BookmarkExistsFor(a:name) if s:Bookmark.BookmarkExistsFor(a:name)
let path = s:Bookmark.BookmarkFor(a:name).path let path = s:Bookmark.BookmarkFor(a:name).path
else else
let dir = a:name == '' ? getcwd() : a:name let dir = a:name ==# '' ? getcwd() : a:name
"hack to get an absolute path if a relative path is given "hack to get an absolute path if a relative path is given
if dir =~ '^\.' if dir =~ '^\.'
@@ -2194,12 +2194,12 @@ function! s:initNerdTreeMirror()
let choices = ["Choose a tree to mirror"] let choices = ["Choose a tree to mirror"]
let choices = extend(choices, sort(keys(options))) let choices = extend(choices, sort(keys(options)))
let choice = inputlist(choices) let choice = inputlist(choices)
if choice < 1 || choice > len(options) || choice == '' if choice < 1 || choice > len(options) || choice ==# ''
return return
endif endif
let bufferName = options[keys(options)[choice-1]] let bufferName = options[keys(options)[choice-1]]
elseif len(keys(options)) == 1 elseif len(keys(options)) ==# 1
let bufferName = values(options)[0] let bufferName = values(options)[0]
else else
call s:echo("No trees to mirror") call s:echo("No trees to mirror")
@@ -2256,7 +2256,7 @@ endfunction
function! s:unique(list) function! s:unique(list)
let uniqlist = [] let uniqlist = []
for elem in a:list for elem in a:list
if index(uniqlist, elem) == -1 if index(uniqlist, elem) ==# -1
let uniqlist += [elem] let uniqlist += [elem]
endif endif
endfor endfor
@@ -2353,7 +2353,7 @@ endfunction
"options etc "options etc
function! s:createTreeWin() function! s:createTreeWin()
"create the nerd tree window "create the nerd tree window
let splitLocation = g:NERDTreeWinPos == "left" ? "topleft " : "botright " let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
let splitSize = g:NERDTreeWinSize let splitSize = g:NERDTreeWinSize
silent! exec splitLocation . 'vertical ' . splitSize . ' new' silent! exec splitLocation . 'vertical ' . splitSize . ' new'
@@ -2399,17 +2399,17 @@ endfunction
"prints out the quick help "prints out the quick help
function! s:dumpHelp() function! s:dumpHelp()
let old_h = @h let old_h = @h
if b:treeShowHelp == 1 if b:treeShowHelp ==# 1
let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n" let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n"
let @h=@h."\" ============================\n" let @h=@h."\" ============================\n"
let @h=@h."\" File node mappings~\n" let @h=@h."\" File node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode == 3 ? "single" : "double") ."-click,\n" let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
if b:NERDTreeType == "primary" if b:NERDTreeType ==# "primary"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else else
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
endif endif
if b:NERDTreeType == "primary" if b:NERDTreeType ==# "primary"
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
endif endif
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
@@ -2423,7 +2423,7 @@ function! s:dumpHelp()
let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Directory node mappings~\n" let @h=@h."\" Directory node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode == 1 ? "double" : "single") ."-click,\n" let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n"
let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
@@ -2522,7 +2522,7 @@ function! s:firstNormalWindow()
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')
return i return i
endif endif
@@ -2554,7 +2554,7 @@ function! s:getPath(ln)
return {} return {}
endif endif
if line == s:tree_up_dir_line if line ==# s:tree_up_dir_line
return b:NERDTreeRoot.path.getParent() return b:NERDTreeRoot.path.getParent()
endif endif
@@ -2637,7 +2637,7 @@ endfunction
"winnumber: the number of the window in question "winnumber: the number of the window in question
function! s:isWindowUsable(winnumber) function! s:isWindowUsable(winnumber)
"gotta split if theres only one window (i.e. the NERD tree) "gotta split if theres only one window (i.e. the NERD tree)
if winnr("$") == 1 if winnr("$") ==# 1
return 0 return 0
endif endif
@@ -2665,7 +2665,7 @@ endfunction
" direction: 0 if going to first child, 1 if going to last " direction: 0 if going to first child, 1 if going to last
function! s:jumpToChild(direction) function! s:jumpToChild(direction)
let currentNode = s:TreeFileNode.GetSelected() let currentNode = s:TreeFileNode.GetSelected()
if currentNode == {} || currentNode.isRoot() if currentNode ==# {} || currentNode.isRoot()
call s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child") call s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child")
return return
end end
@@ -2701,7 +2701,7 @@ endfunction
" del the buffer " del the buffer
function! s:promptToDelBuffer(bufnum, msg) function! s:promptToDelBuffer(bufnum, msg)
echo a:msg echo a:msg
if nr2char(getchar()) == 'y' if nr2char(getchar()) ==# 'y'
exec "silent bdelete! " . a:bufnum exec "silent bdelete! " . a:bufnum
endif endif
endfunction endfunction
@@ -2977,7 +2977,7 @@ function! s:stripMarkupFromLine(line, removeLeadingSpaces)
let wasdir = 1 let wasdir = 1
endif endif
let line = substitute (line,' -> .*',"","") " remove link to let line = substitute (line,' -> .*',"","") " remove link to
if wasdir == 1 if wasdir ==# 1
let line = substitute (line, '/\?$', '/', "") let line = substitute (line, '/\?$', '/', "")
endif endif
@@ -3019,7 +3019,7 @@ endfunction
"args: "args:
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set "forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
function! s:activateNode(forceKeepWindowOpen) function! s:activateNode(forceKeepWindowOpen)
if getline(".") == s:tree_up_dir_line if getline(".") ==# s:tree_up_dir_line
return s:upDir(0) return s:upDir(0)
endif endif
@@ -3149,7 +3149,7 @@ function! s:checkForActivate()
endif endif
endif endif
if (g:NERDTreeMouseMode == 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode == 3 if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
if char !~ s:tree_markup_reg && startToCur !~ '\/$' if char !~ s:tree_markup_reg && startToCur !~ '\/$'
call s:activateNode(0) call s:activateNode(0)
return return
@@ -3161,7 +3161,7 @@ endfunction
" FUNCTION: s:chCwd() {{{2 " FUNCTION: s:chCwd() {{{2
function! s:chCwd() function! s:chCwd()
let treenode = s:TreeFileNode.GetSelected() let treenode = s:TreeFileNode.GetSelected()
if treenode == {} if treenode ==# {}
call s:echo("Select a node first") call s:echo("Select a node first")
return return
endif endif
@@ -3177,7 +3177,7 @@ endfunction
" changes the current root to the selected one " changes the current root to the selected one
function! s:chRoot() function! s:chRoot()
let treenode = s:TreeFileNode.GetSelected() let treenode = s:TreeFileNode.GetSelected()
if treenode == {} if treenode ==# {}
call s:echo("Select a node first") call s:echo("Select a node first")
return return
endif endif
@@ -3189,7 +3189,7 @@ endfunction
" FUNCTION: s:clearBookmarks(bookmarks) {{{2 " FUNCTION: s:clearBookmarks(bookmarks) {{{2
function! s:clearBookmarks(bookmarks) function! s:clearBookmarks(bookmarks)
if a:bookmarks == '' if a:bookmarks ==# ''
let currentNode = s:TreeFileNode.GetSelected() let currentNode = s:TreeFileNode.GetSelected()
if currentNode != {} if currentNode != {}
call currentNode.clearBoomarks() call currentNode.clearBoomarks()
@@ -3206,7 +3206,7 @@ endfunction
" closes all childnodes of the current node " closes all childnodes of the current node
function! s:closeChildren() function! s:closeChildren()
let currentNode = s:TreeDirNode.GetSelected() let currentNode = s:TreeDirNode.GetSelected()
if currentNode == {} if currentNode ==# {}
call s:echo("Select a node first") call s:echo("Select a node first")
return return
endif endif
@@ -3219,7 +3219,7 @@ endfunction
" closes the parent dir of the current node " closes the parent dir of the current node
function! s:closeCurrentDir() function! s:closeCurrentDir()
let treenode = s:TreeFileNode.GetSelected() let treenode = s:TreeFileNode.GetSelected()
if treenode == {} if treenode ==# {}
call s:echo("Select a node first") call s:echo("Select a node first")
return return
endif endif
@@ -3236,7 +3236,7 @@ endfunction
" FUNCTION: s:closeTreeWindow() {{{2 " FUNCTION: s:closeTreeWindow() {{{2
" close the tree window " close the tree window
function! s:closeTreeWindow() function! s:closeTreeWindow()
if b:NERDTreeType == "secondary" && b:NERDTreePreviousBuf != -1 if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
exec "buffer " . b:NERDTreePreviousBuf exec "buffer " . b:NERDTreePreviousBuf
else else
if winnr("$") > 1 if winnr("$") > 1
@@ -3249,7 +3249,7 @@ endfunction
" FUNCTION: s:copyNode() {{{2 " FUNCTION: s:copyNode() {{{2
function! s:copyNode() function! s:copyNode()
let currentNode = s:TreeFileNode.GetSelected() let currentNode = s:TreeFileNode.GetSelected()
if currentNode == {} if currentNode ==# {}
call s:echo("Put the cursor on a file node first") call s:echo("Put the cursor on a file node first")
return return
endif endif
@@ -3267,7 +3267,7 @@ function! s:copyNode()
if currentNode.path.copyingWillOverwrite(newNodePath) if currentNode.path.copyingWillOverwrite(newNodePath)
call s:echo("\nWarning: copying may overwrite files! Continue? (yN)") call s:echo("\nWarning: copying may overwrite files! Continue? (yN)")
let choice = nr2char(getchar()) let choice = nr2char(getchar())
let confirmed = choice == 'y' let confirmed = choice ==# 'y'
endif endif
if confirmed if confirmed
@@ -3289,14 +3289,14 @@ endfunction
" if the cursor is on a bookmark, prompt to delete " if the cursor is on a bookmark, prompt to delete
function! s:deleteBookmark() function! s:deleteBookmark()
let bookmark = s:getSelectedBookmark() let bookmark = s:getSelectedBookmark()
if bookmark == {} if bookmark ==# {}
call s:echo("Put the cursor on a bookmark") call s:echo("Put the cursor on a bookmark")
return return
endif endif
echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):" echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):"
if nr2char(getchar()) == 'y' if nr2char(getchar()) ==# 'y'
try try
call bookmark.delete() call bookmark.delete()
call s:renderView() call s:renderView()
@@ -3315,7 +3315,7 @@ endfunction
" to delete it " to delete it
function! s:deleteNode() function! s:deleteNode()
let currentNode = s:TreeFileNode.GetSelected() let currentNode = s:TreeFileNode.GetSelected()
if currentNode == {} if currentNode ==# {}
call s:echo("Put the cursor on a file node first") call s:echo("Put the cursor on a file node first")
return return
endif endif
@@ -3327,14 +3327,14 @@ function! s:deleteNode()
\ "==========================================================\n" . \ "==========================================================\n" .
\ "STOP! To delete this entire directory, type 'yes'\n" . \ "STOP! To delete this entire directory, type 'yes'\n" .
\ "" . currentNode.path.strForOS(0) . ": ") \ "" . currentNode.path.strForOS(0) . ": ")
let confirmed = choice == 'yes' let confirmed = choice ==# 'yes'
else else
echo "Delete the current node\n" . echo "Delete the current node\n" .
\ "==========================================================\n". \ "==========================================================\n".
\ "Are you sure you wish to delete the node:\n" . \ "Are you sure you wish to delete the node:\n" .
\ "" . currentNode.path.strForOS(0) . " (yN):" \ "" . currentNode.path.strForOS(0) . " (yN):"
let choice = nr2char(getchar()) let choice = nr2char(getchar())
let confirmed = choice == 'y' let confirmed = choice ==# 'y'
endif endif
@@ -3347,7 +3347,7 @@ function! s:deleteNode()
"close that buffer "close that buffer
let bufnum = bufnr(currentNode.path.str(0)) let bufnum = bufnr(currentNode.path.str(0))
if buflisted(bufnum) if buflisted(bufnum)
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) == -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt) call s:promptToDelBuffer(bufnum, prompt)
endif endif
@@ -3372,7 +3372,7 @@ endfunction
" FUNCTION: s:executeNode() {{{2 " FUNCTION: s:executeNode() {{{2
function! s:executeNode() function! s:executeNode()
let treenode = s:TreeFileNode.GetSelected() let treenode = s:TreeFileNode.GetSelected()
if treenode == {} || treenode.path.isDirectory if treenode ==# {} || treenode.path.isDirectory
call s:echo("Select an executable file node first" ) call s:echo("Select an executable file node first" )
else else
echo "NERDTree executor\n" . echo "NERDTree executor\n" .
@@ -3392,7 +3392,7 @@ endfunction
" FUNCTION: s:handleMiddleMouse() {{{2 " FUNCTION: s:handleMiddleMouse() {{{2
function! s:handleMiddleMouse() function! s:handleMiddleMouse()
let curNode = s:TreeFileNode.GetSelected() let curNode = s:TreeFileNode.GetSelected()
if curNode == {} if curNode ==# {}
call s:echo("Put the cursor on a node first" ) call s:echo("Put the cursor on a node first" )
return return
endif endif
@@ -3409,7 +3409,7 @@ endfunction
" Adds a new node to the filesystem and then into the tree " Adds a new node to the filesystem and then into the tree
function! s:insertNewNode() function! s:insertNewNode()
let curDirNode = s:TreeDirNode.GetSelected() let curDirNode = s:TreeDirNode.GetSelected()
if curDirNode == {} if curDirNode ==# {}
call s:echo("Put the cursor on a node first" ) call s:echo("Put the cursor on a node first" )
return return
endif endif
@@ -3419,7 +3419,7 @@ function! s:insertNewNode()
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" . \ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
\ "", curDirNode.path.strForGlob() . s:os_slash) \ "", curDirNode.path.strForGlob() . s:os_slash)
if newNodeName == '' if newNodeName ==# ''
call s:echo("Node Creation Aborted.") call s:echo("Node Creation Aborted.")
return return
endif endif
@@ -3579,7 +3579,7 @@ endfunction
" FUNCTION: s:openNodeRecursively() {{{2 " FUNCTION: s:openNodeRecursively() {{{2
function! s:openNodeRecursively() function! s:openNodeRecursively()
let treenode = s:TreeFileNode.GetSelected() let treenode = s:TreeFileNode.GetSelected()
if treenode == {} || treenode.path.isDirectory == 0 if treenode ==# {} || treenode.path.isDirectory ==# 0
call s:echo("Select a directory node first" ) call s:echo("Select a directory node first" )
else else
call s:echo("Recursively opening node. Please wait...") call s:echo("Recursively opening node. Please wait...")
@@ -3598,7 +3598,7 @@ endfunction
function! s:previewNode(openNewWin) function! s:previewNode(openNewWin)
let currentBuf = bufnr("") let currentBuf = bufnr("")
if a:openNewWin > 0 if a:openNewWin > 0
call s:openEntrySplit(a:openNewWin == 2,1) call s:openEntrySplit(a:openNewWin ==# 2,1)
else else
call s:activateNode(1) call s:activateNode(1)
end end
@@ -3630,7 +3630,7 @@ endfunction
" refreshes the root for the current node " refreshes the root for the current node
function! s:refreshCurrent() function! s:refreshCurrent()
let treenode = s:TreeDirNode.GetSelected() let treenode = s:TreeDirNode.GetSelected()
if treenode == {} if treenode ==# {}
call s:echo("Refresh failed. Select a node first") call s:echo("Refresh failed. Select a node first")
return return
endif endif
@@ -3645,7 +3645,7 @@ endfunction
" allows the user to rename the current node " allows the user to rename the current node
function! s:renameCurrent() function! s:renameCurrent()
let curNode = s:TreeFileNode.GetSelected() let curNode = s:TreeFileNode.GetSelected()
if curNode == {} if curNode ==# {}
call s:echo("Put the cursor on a node first" ) call s:echo("Put the cursor on a node first" )
return return
endif endif
@@ -3655,7 +3655,7 @@ function! s:renameCurrent()
\ "Enter the new path for the node: \n" . \ "Enter the new path for the node: \n" .
\ "", curNode.path.strForOS(0)) \ "", curNode.path.strForOS(0))
if newNodePath == '' if newNodePath ==# ''
call s:echo("Node Renaming Aborted.") call s:echo("Node Renaming Aborted.")
return return
endif endif
@@ -3669,7 +3669,7 @@ function! s:renameCurrent()
"if the node is open in a buffer, ask the user if they want to "if the node is open in a buffer, ask the user if they want to
"close that buffer "close that buffer
if bufnum != -1 if bufnum != -1
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) == -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt) call s:promptToDelBuffer(bufnum, prompt)
endif endif
@@ -3684,7 +3684,7 @@ endfunction
" FUNCTION: s:showFileSystemMenu() {{{2 " FUNCTION: s:showFileSystemMenu() {{{2
function! s:showFileSystemMenu() function! s:showFileSystemMenu()
let curNode = s:TreeFileNode.GetSelected() let curNode = s:TreeFileNode.GetSelected()
if curNode == {} if curNode ==# {}
call s:echo("Put the cursor on a node first" ) call s:echo("Put the cursor on a node first" )
return return
endif endif
@@ -3761,7 +3761,7 @@ endfunction
"re-rendered "re-rendered
function! s:upDir(keepState) function! s:upDir(keepState)
let cwd = b:NERDTreeRoot.path.str(0) let cwd = b:NERDTreeRoot.path.str(0)
if cwd == "/" || cwd =~ '^[^/]..$' if cwd ==# "/" || cwd =~ '^[^/]..$'
call s:echo("already at top dir") call s:echo("already at top dir")
else else
if !a:keepState if !a:keepState
@@ -3780,7 +3780,7 @@ function! s:upDir(keepState)
let b:NERDTreeRoot = b:NERDTreeRoot.parent let b:NERDTreeRoot = b:NERDTreeRoot.parent
endif endif
if g:NERDTreeChDirMode == 2 if g:NERDTreeChDirMode ==# 2
exec 'cd ' . b:NERDTreeRoot.path.strForCd() exec 'cd ' . b:NERDTreeRoot.path.strForCd()
endif endif