Compare commits

...

8 Commits
6.9.3 ... 6.9.8

Author SHA1 Message Date
Phil Runninger
23000acd7f Refactor sort comparison functions, removing redundancy (#1166)
* Add a function to compare path objects.

* Remove redundant node comparison function, and rename the ones left.

* Remove the compareTo function in the Path object.

Use nerdtree#compareNodePaths(p1,p2) instead. There was no need for two
comparison functions that do the same thing. They were a little
different in their details, but that shouldn't be the case. Having only
one such function makes better sense and is easier to maintain.

* Update version number in change log.
2020-08-14 18:06:03 -04:00
Phil Runninger
6b5d70e5bf Fix argument of exists() function calls checking for autocommands. (#1165)
* Fix syntax of exists function calls checking for autocommands.

* Update version number in change log.
2020-08-09 07:07:55 -04:00
Phil Runninger
373a4b28e4 Don't use silent when raising User events (#1164)
* Remove silent from doautocmd. Prevent errors with exists('#...').

* Update version number in change log.
2020-08-07 00:37:56 -04:00
Yeri Pratama
4a32dd0be3 fix highlight for file node (#1157)
* fix #960 953 highlight for file node

* update changelog
2020-07-24 11:14:54 -04:00
Phil Runninger
e571d3e95b Make sure symbolic links' flags are highlighted correctly. (#1156)
* Make sure symbolic links' flags are higlighted correctly.

* Update version number in change log.
2020-07-17 14:11:08 -04:00
Phil Runninger
96e247ba74 Respect user's &shellslash setting in CopyNode and RemoveNode functions (#1150)
* Replace s:Path.Slash() with nerdtree#slash().

* Check the value of &shell when determining the slash under Windows.

* Leave &shellslash unchanged when forming copy/delete commands.

* Fix fold marker.

* Update version number in change log.

* Add abort attribute to nerdtree#slash() to satisfy Vim style guide.

Co-authored-by: Phil Runninger <prunninger@vhtcx.com>
2020-07-14 08:53:00 -04:00
Phil Runninger
2af10e3589 Update PULL_REQUEST_TEMPLATE.md
Use a shorter command to display the recent patches: replace `| head -2` with `-m2` grep switch; replace a `sed` with `cut` to get the line numbers.
2020-07-14 08:49:44 -04:00
Phil Runninger
42a5a2c106 Update PULL_REQUEST_TEMPLATE.md
Make the tag creation process semi-automatic by making bash do more of the legwork. The included bash commands will:

1. Make sure your master branch is up to date
2. Display all the patch releases in the current MAJOR.MINOR version
3. Ask for a version number to use as the tag (one of the ones previously displayed, presumably)
4. Get the latest commit's subject line, and use it in the tag's message field.
5. Create the tag, and push all tags to the origin.
2020-07-14 08:32:29 -04:00
9 changed files with 45 additions and 92 deletions

View File

@@ -1,5 +1,5 @@
### Description of Changes ### Description of Changes
Closes # <!-- Issue number this PR addresses. If none, remove this line. --> Closes # <!-- Enter the issue number this PR addresses. If none, remove this line. -->
--- ---
@@ -13,4 +13,10 @@ Closes # <!-- Issue number this PR addresses. If none, remove this line. -->
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern.
#### Collaborator's Instructions #### Collaborator's Instructions
- [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. - [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary.
- [ ] After merge, tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` - [ ] After merging, tag the commit using these (Mac-compatible) bash commands:
```bash
git checkout master
git pull
sed -n "$(grep -n -m2 '####' CHANGELOG.md | cut -f1 -d: | sed 'N;s/\n/,/')p" CHANGELOG.md | sed '$d'
git tag -a $(read -p "Tag Name: " tag;echo $tag) -m"$(git show --quiet --pretty=%s)";git push origin --tags
```

View File

@@ -5,8 +5,14 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
--> -->
#### 6.9 #### 6.9
- **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166)
- **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165)
- **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164)
- **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157)
- **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156)
- **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) - **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153)
- **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) - **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151)
- **.1**: Respect user's `&shellslash` setting in CopyNode and RemoveNode functions (PhilRunninger) [#1150](https://github.com/preservim/nerdtree/pull/1150)
- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) - **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144)
#### 6.8 #### 6.8
- **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) - **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138)

View File

@@ -30,9 +30,11 @@ endfunction
" SECTION: General Functions {{{1 " SECTION: General Functions {{{1
"============================================================ "============================================================
"FUNCTION: nerdtree#slash() {{{2 " FUNCTION: nerdtree#slash() {{{2
" Return the path separator used by the underlying file system. Special
" consideration is taken for the use of the 'shellslash' option on Windows
" systems.
function! nerdtree#slash() abort function! nerdtree#slash() abort
if nerdtree#runningWindows() if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash if exists('+shellslash') && &shellslash
return '/' return '/'
@@ -108,15 +110,15 @@ function! nerdtree#completeBookmarks(A,L,P) abort
return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
endfunction endfunction
"FUNCTION: nerdtree#compareNodes(dir) {{{2 "FUNCTION: nerdtree#compareNodes(n1, n2) {{{2
function! nerdtree#compareNodes(n1, n2) abort function! nerdtree#compareNodes(n1, n2) abort
return a:n1.path.compareTo(a:n2.path) return nerdtree#compareNodePaths(a:n1.path, a:n2.path)
endfunction endfunction
"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 "FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2
function! nerdtree#compareNodesBySortKey(n1, n2) abort function! nerdtree#compareNodePaths(p1, p2) abort
let sortKey1 = a:n1.path.getSortKey() let sortKey1 = a:p1.getSortKey()
let sortKey2 = a:n2.path.getSortKey() let sortKey2 = a:p2.getSortKey()
let i = 0 let i = 0
while i < min([len(sortKey1), len(sortKey2)]) while i < min([len(sortKey1), len(sortKey2)])
" Compare chunks upto common length. " Compare chunks upto common length.

View File

@@ -28,7 +28,9 @@ endfunction
" FUNCTION: s:Creator._broadcastInitEvent() {{{1 " FUNCTION: s:Creator._broadcastInitEvent() {{{1
function! s:Creator._broadcastInitEvent() function! s:Creator._broadcastInitEvent()
silent doautocmd User NERDTreeInit if exists('#User#NERDTreeInit')
doautocmd User NERDTreeInit
endif
endfunction endfunction
" FUNCTION: s:Creator.BufNamePrefix() {{{1 " FUNCTION: s:Creator.BufNamePrefix() {{{1
@@ -247,7 +249,7 @@ function! s:Creator._pathForString(str)
"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 =~# '^\.'
let dir = getcwd() . g:NERDTreePath.Slash() . dir let dir = getcwd() . nerdtree#slash() . dir
endif endif
"hack to prevent removing slash if dir is the root of the file system. "hack to prevent removing slash if dir is the root of the file system.

View File

@@ -27,7 +27,9 @@ function! s:NERDTree.changeRoot(node)
call self.render() call self.render()
call self.root.putCursorHere(0, 0) call self.root.putCursorHere(0, 0)
silent doautocmd User NERDTreeNewRoot if exists('#User#NERDTreeNewRoot')
doautocmd User NERDTreeNewRoot
endif
endfunction endfunction
"FUNCTION: s:NERDTree.Close() {{{1 "FUNCTION: s:NERDTree.Close() {{{1

View File

@@ -25,10 +25,10 @@ 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:] == nerdtree#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 . nerdtree#slash() . a:pathStr
endif endif
endif endif
@@ -99,50 +99,6 @@ function! s:Path.changeToDir()
endtry endtry
endfunction endfunction
" FUNCTION: Path.compareTo() {{{1
"
" Compares this Path to the given path and returns 0 if they are equal, -1 if
" this Path is 'less than' the given path, or 1 if it is 'greater'.
"
" Args:
" path: the path object to compare this to
"
" Return:
" 1, -1 or 0
function! s:Path.compareTo(path)
let thisPath = self.getLastPathComponent(1)
let thatPath = a:path.getLastPathComponent(1)
"if the paths are the same then clearly we return 0
if thisPath ==# thatPath
return 0
endif
let thisSS = self.getSortOrderIndex()
let thatSS = a:path.getSortOrderIndex()
"compare the sort sequences, if they are different then the return
"value is easy
if thisSS < thatSS
return -1
elseif thisSS > thatSS
return 1
else
if !g:NERDTreeSortHiddenFirst
let thisPath = substitute(thisPath, '^[._]', '', '')
let thatPath = substitute(thatPath, '^[._]', '', '')
endif
"if the sort sequences are the same then compare the paths
"alphabetically
let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
if pathCompare
return -1
else
return 1
endif
endif
endfunction
" FUNCTION: Path.Create(fullpath) {{{1 " FUNCTION: Path.Create(fullpath) {{{1
" "
" Factory method. " Factory method.
@@ -614,23 +570,6 @@ function! s:Path.New(pathStr)
return l:newPath return l:newPath
endfunction endfunction
" FUNCTION: Path.Slash() {{{1
" Return the path separator used by the underlying file system. Special
" consideration is taken for the use of the 'shellslash' option on Windows
" systems.
function! s:Path.Slash()
if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash
return '/'
endif
return '\'
endif
return '/'
endfunction
" FUNCTION: Path.Resolve() {{{1 " FUNCTION: Path.Resolve() {{{1
" Invoke the vim resolve() function and return the result " Invoke the vim resolve() function and return the result
" This is necessary because in some versions of vim resolve() removes trailing " This is necessary because in some versions of vim resolve() removes trailing
@@ -815,7 +754,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] == nerdtree#slash()
let l:result = self.drive . l:result let l:result = self.drive . l:result
endif endif
@@ -830,14 +769,14 @@ endfunction
" FUNCTION: Path._strForGlob() {{{1 " FUNCTION: Path._strForGlob() {{{1
function! s:Path._strForGlob() function! s:Path._strForGlob()
let lead = s:Path.Slash() let lead = nerdtree#slash()
"if we are running windows then slap a drive letter on the front "if we are running windows then slap a drive letter on the front
if nerdtree#runningWindows() if nerdtree#runningWindows()
let lead = self.drive . '\' let lead = self.drive . '\'
endif endif
let toReturn = lead . join(self.pathSegments, s:Path.Slash()) let toReturn = lead . join(self.pathSegments, nerdtree#slash())
if !nerdtree#runningWindows() if !nerdtree#runningWindows()
let toReturn = escape(toReturn, self._escChars()) let toReturn = escape(toReturn, self._escChars())
@@ -849,7 +788,7 @@ endfunction
" Return the absolute pathname associated with this Path object. The pathname " Return the absolute pathname associated with this Path object. The pathname
" returned is appropriate for the underlying file system. " returned is appropriate for the underlying file system.
function! s:Path._str() function! s:Path._str()
let l:separator = s:Path.Slash() let l:separator = nerdtree#slash()
let l:leader = l:separator let l:leader = l:separator
if nerdtree#runningWindows() if nerdtree#runningWindows()

View File

@@ -236,7 +236,7 @@ function! s:TreeDirNode.getChildIndex(path)
let z = self.getChildCount() let z = self.getChildCount()
while a < z while a < z
let mid = (a+z)/2 let mid = (a+z)/2
let diff = a:path.compareTo(self.children[mid].path) let diff = nerdtree#compareNodePaths(a:path, self.children[mid].path)
if diff ==# -1 if diff ==# -1
let z = mid let z = mid
@@ -278,8 +278,8 @@ function! s:TreeDirNode._glob(pattern, all)
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] == nerdtree#slash()
let l:pathSpec = self.path.drive . l:pathSpec let l:pathSpec = self.path.drive . l:pathSpec
endif endif
endif endif
@@ -666,7 +666,7 @@ function! s:TreeDirNode.sortChildren()
if count(g:NERDTreeSortOrder, '*') < 1 if count(g:NERDTreeSortOrder, '*') < 1
call add(g:NERDTreeSortOrder, '*') call add(g:NERDTreeSortOrder, '*')
endif endif
let CompareFunc = function('nerdtree#compareNodesBySortKey') let CompareFunc = function('nerdtree#compareNodes')
call sort(self.children, CompareFunc) call sort(self.children, CompareFunc)
let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder
endfunction endfunction

View File

@@ -165,7 +165,7 @@ endfunction
function! NERDTreeAddNode() function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected() let curDirNode = g:NERDTreeDirNode.GetSelected()
let prompt = s:inputPrompt('add') let prompt = s:inputPrompt('add')
let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), 'file') let newNodeName = input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file')
if newNodeName ==# '' if newNodeName ==# ''
call nerdtree#echo('Node Creation Aborted.') call nerdtree#echo('Node Creation Aborted.')
@@ -252,8 +252,6 @@ endfunction
" FUNCTION: NERDTreeDeleteNode() {{{1 " FUNCTION: NERDTreeDeleteNode() {{{1
function! NERDTreeDeleteNode() function! NERDTreeDeleteNode()
let l:shellslash = &shellslash
let &shellslash = 0
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0 let confirmed = 0
@@ -289,7 +287,6 @@ function! NERDTreeDeleteNode()
else else
call nerdtree#echo('delete aborted') call nerdtree#echo('delete aborted')
endif endif
let &shellslash = l:shellslash
endfunction endfunction
" FUNCTION: NERDTreeListNode() {{{1 " FUNCTION: NERDTreeListNode() {{{1
@@ -334,8 +331,6 @@ endfunction
" FUNCTION: NERDTreeCopyNode() {{{1 " FUNCTION: NERDTreeCopyNode() {{{1
function! NERDTreeCopyNode() function! NERDTreeCopyNode()
let l:shellslash = &shellslash
let &shellslash = 0
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
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')
@@ -371,7 +366,6 @@ function! NERDTreeCopyNode()
else else
call nerdtree#echo('Copy aborted.') call nerdtree#echo('Copy aborted.')
endif endif
let &shellslash = l:shellslash
redraw! redraw!
endfunction endfunction

View File

@@ -47,7 +47,7 @@ endif
"highlighting for readonly files "highlighting for readonly files
exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile'
exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeDir' exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir'
syn match NERDTreeCWD #^[</].*$# syn match NERDTreeCWD #^[</].*$#
@@ -93,3 +93,5 @@ hi def link NERDTreeBookmark Statement
hi def link NERDTreeFlags Number hi def link NERDTreeFlags Number
hi def link NERDTreeCurrentNode Search hi def link NERDTreeCurrentNode Search
hi NERDTreeFile ctermbg=NONE guibg=NONE