mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4a7ca084e | ||
|
|
184fbb6ffe | ||
|
|
03073bb1c8 | ||
|
|
858b3c0004 | ||
|
|
ae1c0004ec | ||
|
|
63c59208c1 |
16
.github/ISSUE_TEMPLATE/bug.md
vendored
16
.github/ISSUE_TEMPLATE/bug.md
vendored
@@ -3,18 +3,18 @@ name: "Bug Report"
|
||||
about: "NERDTree is misbehaving? Tell us about it."
|
||||
labels: bug
|
||||
---
|
||||
<!-- Attention! Please Read!
|
||||
|
||||
# Attention! Please Read!
|
||||
Please fill out ALL the information below so that the issue can be fully
|
||||
understood. Omitting information will delay the resolution of your issue. It
|
||||
will be labeled "Needs More Info", and may be closed until there is enough
|
||||
information.
|
||||
|
||||
Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information.
|
||||
|
||||
Keep in mind that others may have the same question in the future. The better your information, the more likely they'll be able to help themselves.
|
||||
|
||||
After reading, and before submitting your issue, please remove this introductory text.
|
||||
|
||||
──────────────────── ✄ ────────────────────
|
||||
Keep in mind that others may have the same question in the future. The better
|
||||
your information, the more likely they'll be able to help themselves. -->
|
||||
|
||||
#### Self-Diagnosis
|
||||
<!-- Check the boxes after creating the issue, or use [x]. -->
|
||||
- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question.
|
||||
- [ ] I have reviewed the NERDTree documentation. `:h NERDTree`
|
||||
- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki).
|
||||
|
||||
16
.github/ISSUE_TEMPLATE/question.md
vendored
16
.github/ISSUE_TEMPLATE/question.md
vendored
@@ -3,18 +3,18 @@ name: "General Question"
|
||||
about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here."
|
||||
labels: "general question"
|
||||
---
|
||||
<!-- Attention! Please Read!
|
||||
|
||||
# Attention! Please Read!
|
||||
Please fill out ALL the information below so that the issue can be fully
|
||||
understood. Omitting information will delay the resolution of your issue. It
|
||||
will be labeled "Needs More Info", and may be closed until there is enough
|
||||
information.
|
||||
|
||||
Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information.
|
||||
|
||||
Keep in mind that others may have the same question in the future. The better your information, the more likely they'll be able to help themselves.
|
||||
|
||||
After reading, and before submitting your issue, please remove this introductory text.
|
||||
|
||||
──────────────────── ✄ ────────────────────
|
||||
Keep in mind that others may have the same question in the future. The better
|
||||
your information, the more likely they'll be able to help themselves. -->
|
||||
|
||||
#### Self-Diagnosis
|
||||
<!-- Check the boxes after creating the issue, or use [x]. -->
|
||||
- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question.
|
||||
- [ ] I have reviewed the NERDTree documentation. `:h NERDTree`
|
||||
- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki).
|
||||
|
||||
15
.github/PULL_REQUEST_TEMPLATE.md
vendored
15
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -9,12 +9,11 @@ Closes # <!-- Issue number this PR addresses. If none, remove this line. -->
|
||||
- [ ] `MAJOR` version when you make incompatible API changes
|
||||
- [ ] `MINOR` version when you add functionality in a backwards-compatible manner
|
||||
- [ ] `PATCH` version when you make backwards-compatible bug fixes
|
||||
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following this format/example:
|
||||
```
|
||||
#### MAJOR.MINOR...
|
||||
- **.PATCH**: PR Title (Author) [#PR Number](link to PR)
|
||||
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md).
|
||||
<!--
|
||||
Use this format in CHANGELOG.md. Use the existing text as a template.
|
||||
|
||||
#### 5.1...
|
||||
- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
|
||||
- **.0**: Too many changes for one patch...
|
||||
```
|
||||
#### MAJOR.MINOR...
|
||||
- **.PATCH**: PR Title (Author) [#PR Number](link to PR)
|
||||
|
||||
-->
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
# Change Log
|
||||
|
||||
#### 5.3...
|
||||
- **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029)
|
||||
#### 5.2...
|
||||
- **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026)
|
||||
- **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021)
|
||||
- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019)
|
||||
- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017)
|
||||
- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016)
|
||||
|
||||
@@ -22,24 +22,8 @@ endfunction
|
||||
" SECTION: General Functions {{{1
|
||||
"============================================================
|
||||
|
||||
"FUNCTION: nerdtree#redraw(bang)
|
||||
" Redraws the screen (Neovim uses the mode statement). If bang is TRUE, use
|
||||
" redraw! instead of redraw.
|
||||
function! nerdtree#redraw(bang)
|
||||
if has('nvim')
|
||||
mode
|
||||
else
|
||||
if a:bang
|
||||
redraw!
|
||||
else
|
||||
redraw
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#slash()
|
||||
" Returns the directory separator based on OS and &shellslash
|
||||
function! nerdtree#slash()
|
||||
|
||||
if nerdtree#runningWindows()
|
||||
if exists('+shellslash') && &shellslash
|
||||
return '/'
|
||||
@@ -170,13 +154,13 @@ function! nerdtree#deprecated(func, ...)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#exec(cmd) {{{2
|
||||
" Same as :exec cmd but with eventignore set for the duration
|
||||
" to disable the autocommands used by NERDTree (BufEnter,
|
||||
" BufLeave and VimEnter)
|
||||
function! nerdtree#exec(cmd)
|
||||
" FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2
|
||||
" Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration
|
||||
function! nerdtree#exec(cmd, ignoreAll)
|
||||
let old_ei = &ei
|
||||
set ei=BufEnter,BufLeave,VimEnter
|
||||
if a:ignoreAll
|
||||
set ei=all
|
||||
endif
|
||||
exec a:cmd
|
||||
let &ei = old_ei
|
||||
endfunction
|
||||
@@ -232,7 +216,7 @@ endfunction
|
||||
"Args:
|
||||
"msg: the message to echo
|
||||
function! nerdtree#echo(msg)
|
||||
call nerdtree#redraw(0)
|
||||
redraw
|
||||
echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg)
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ function! s:deleteBookmark(bookmark)
|
||||
|
||||
let l:choices = "&Yes\n&No"
|
||||
|
||||
echo | call nerdtree#redraw(0)
|
||||
echo | redraw
|
||||
let l:selection = confirm(l:message, l:choices, 1, 'Warning')
|
||||
|
||||
if l:selection != 1
|
||||
@@ -266,7 +266,7 @@ function! s:deleteBookmark(bookmark)
|
||||
call a:bookmark.delete()
|
||||
silent call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
echo | call nerdtree#redraw(0)
|
||||
echo | redraw
|
||||
catch /^NERDTree/
|
||||
call nerdtree#echoWarning('could not remove bookmark')
|
||||
endtry
|
||||
@@ -574,11 +574,11 @@ function! s:refreshRoot()
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while...")
|
||||
|
||||
let l:curWin = winnr()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1)
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
call nerdtree#redraw(0)
|
||||
call nerdtree#exec(l:curWin . "wincmd w")
|
||||
redraw
|
||||
call nerdtree#exec(l:curWin . "wincmd w", 1)
|
||||
call nerdtree#echo("")
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -1043,28 +1043,31 @@ window. Use one of the follow lines for this setting: >
|
||||
Values: a list of regular expressions.
|
||||
Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
||||
|
||||
This setting is a list of regular expressions which are used to specify the
|
||||
order of nodes under their parent.
|
||||
This setting is a list of regular expressions which are used to group or sort
|
||||
the nodes under their parent.
|
||||
|
||||
For example, if the setting is: >
|
||||
['\.vim$', '\.c$', '\.h$', '*', 'foobar']
|
||||
<
|
||||
then all .vim files will be placed at the top, followed by all .c files then
|
||||
then all .vim files will be grouped at the top, followed by all .c files then
|
||||
all .h files. All files containing the string 'foobar' will be placed at the
|
||||
end. The star is a special flag: it tells the script that every node that
|
||||
doesn't match any of the other regexps should be placed here.
|
||||
|
||||
If no star is present in NERDTreeSortOrder then one is automatically
|
||||
appended to the array.
|
||||
If no star is present in NERDTreeSortOrder, then one is automatically
|
||||
appended to the end of the list.
|
||||
|
||||
The regex '\/$' should be used to match directory nodes.
|
||||
|
||||
A special flag can be used to sort by the modification timestamps of files and
|
||||
directories. It is either '[[timestamp]]' for ascending, or '[[-timestamp]]'
|
||||
for descending. If placed at the beginning of the list, files and directories
|
||||
are sorted by timestamp, and then by the remaining items in the sort order
|
||||
list. If this flag is in any other position of the list, timestamp sorting is
|
||||
done secondarily. See examples 4, 5, and 6 below.
|
||||
Files can also be sorted by 1) the modification timestamp, 2) the size, or 3)
|
||||
the extension. Directories are always sorted by name. To accomplish this, the
|
||||
following special flags are used:
|
||||
[[timestamp]] [[-timestamp]] [[size]] [[-size]] [[extension]]
|
||||
The hyphen specifies a descending sort; extensions are sorted in ascending
|
||||
order only. If placed at the beginning of the list, files are sorted according
|
||||
to these flags first, and then grouped by the remaining items in the list. If
|
||||
the flags are in any other position of the list, this special sorting is done
|
||||
secondarily. See examples 4, 5, and 6 below.
|
||||
|
||||
After this sorting is done, the files in each group are sorted alphabetically.
|
||||
|
||||
@@ -1072,20 +1075,20 @@ Examples: >
|
||||
(1) ['*', '\/$']
|
||||
(2) []
|
||||
(3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$']
|
||||
(4) ['[[timestamp]]']
|
||||
(5) ['\/$', '*', '[[-timestamp]]']
|
||||
(6) ['\.md$', '\.c$', '[[-timestamp]]', '*']
|
||||
(4) ['[[-size]]']
|
||||
(5) ['\/$', '*', '[[timestamp]]']
|
||||
(6) ['foo','\/$','[[extension]]']
|
||||
<
|
||||
1. Directories will appear last, everything else will appear above.
|
||||
2. Everything will simply appear in alphabetical order.
|
||||
3. Dirs will appear first, then ruby and php. Swap files, bak files and vim
|
||||
backup files will appear last with everything else preceding them.
|
||||
4. All files and directories are sorted by timestamp, oldest first. If any
|
||||
files have identical timestamps, they are sorted alphabetically.
|
||||
5. Directories are first, newest to oldest, then everything else, newest to
|
||||
oldest.
|
||||
6. Markdown files first, followed by C source files, then everything else.
|
||||
Each group is shown newest to oldest.
|
||||
4. Everything is sorted by size, largest to smallest, with directories
|
||||
considered to have size 0 bytes.
|
||||
5. Directories will appear first alphabetically, followed by files, sorted by
|
||||
timestamp, oldest first.
|
||||
6. Files and directories matching 'foo' first, followed by other directories,
|
||||
then all other files. Each section of files is sorted by file extension.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTreeStatusline*
|
||||
|
||||
@@ -159,8 +159,8 @@ endfunction
|
||||
" FUNCTION: s:Edit() {{{1
|
||||
" opens the NERDTreeBookmarks file for manual editing
|
||||
function! s:Bookmark.Edit()
|
||||
execute "wincmd w"
|
||||
execute "edit ".g:NERDTreeBookmarksFile
|
||||
call nerdtree#exec("wincmd w", 1)
|
||||
call nerdtree#exec("edit ".g:NERDTreeBookmarksFile, 1)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1
|
||||
|
||||
@@ -31,7 +31,11 @@ function! s:MenuController.showMenu()
|
||||
let l:done = 0
|
||||
|
||||
while !l:done
|
||||
call nerdtree#redraw(1)
|
||||
if has('nvim')
|
||||
mode
|
||||
else
|
||||
redraw!
|
||||
endif
|
||||
call self._echoPrompt()
|
||||
|
||||
let l:key = nr2char(getchar())
|
||||
@@ -42,7 +46,7 @@ function! s:MenuController.showMenu()
|
||||
|
||||
" Redraw when "Ctrl-C" or "Esc" is received.
|
||||
if !l:done || self.selection == -1
|
||||
call nerdtree#redraw(1)
|
||||
redraw!
|
||||
endif
|
||||
endtry
|
||||
|
||||
@@ -64,7 +68,7 @@ function! s:MenuController._echoPrompt()
|
||||
|
||||
echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): "
|
||||
else
|
||||
echo "NERDTree Menu. " . navHelp . " . or the shortcuts indicated"
|
||||
echo "NERDTree Menu. " . navHelp . ", or the shortcuts indicated"
|
||||
echo "========================================================="
|
||||
|
||||
for i in range(0, len(self.menuItems)-1)
|
||||
|
||||
@@ -44,19 +44,19 @@ function! s:NERDTree.Close()
|
||||
let l:useWinId = exists('*win_getid') && exists('*win_gotoid')
|
||||
|
||||
if winnr() == s:NERDTree.GetWinNum()
|
||||
call nerdtree#exec("wincmd p")
|
||||
call nerdtree#exec("wincmd p", 1)
|
||||
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("")
|
||||
call nerdtree#exec("wincmd p")
|
||||
call nerdtree#exec("wincmd p", 1)
|
||||
else
|
||||
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("")
|
||||
endif
|
||||
|
||||
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w")
|
||||
close
|
||||
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1)
|
||||
call nerdtree#exec("close", 1)
|
||||
if l:useWinId
|
||||
call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")")
|
||||
call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0)
|
||||
else
|
||||
call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w")
|
||||
call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w", 0)
|
||||
endif
|
||||
else
|
||||
close
|
||||
@@ -98,7 +98,7 @@ endfunction
|
||||
"Places the cursor in the nerd tree window
|
||||
function! s:NERDTree.CursorToTreeWin()
|
||||
call g:NERDTree.MustBeOpen()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1)
|
||||
endfunction
|
||||
|
||||
" Function: s:NERDTree.ExistsForBuffer() {{{1
|
||||
|
||||
@@ -107,10 +107,10 @@ function! s:Opener._isWindowUsable(winnumber)
|
||||
endif
|
||||
|
||||
let oldwinnr = winnr()
|
||||
call nerdtree#exec(a:winnumber . "wincmd p")
|
||||
call nerdtree#exec(a:winnumber . "wincmd p", 1)
|
||||
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
|
||||
let modified = &modified
|
||||
call nerdtree#exec(oldwinnr . "wincmd p")
|
||||
call nerdtree#exec(oldwinnr . "wincmd p", 1)
|
||||
|
||||
"if its a special window e.g. quickfix or another explorer plugin then we
|
||||
"have to split
|
||||
@@ -172,7 +172,7 @@ function! s:Opener._newSplit()
|
||||
let below=0
|
||||
|
||||
" Attempt to go to adjacent window
|
||||
call nerdtree#exec(back)
|
||||
call nerdtree#exec(back, 1)
|
||||
|
||||
let onlyOneWin = (winnr("$") ==# 1)
|
||||
|
||||
@@ -201,9 +201,9 @@ function! s:Opener._newSplit()
|
||||
"resize the tree window if no other window was open before
|
||||
if onlyOneWin
|
||||
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
|
||||
call nerdtree#exec(there)
|
||||
call nerdtree#exec(there, 1)
|
||||
exec("silent ". splitMode ." resize ". size)
|
||||
call nerdtree#exec('wincmd p')
|
||||
call nerdtree#exec('wincmd p', 0)
|
||||
endif
|
||||
|
||||
" Restore splitmode settings
|
||||
@@ -219,8 +219,8 @@ function! s:Opener._newVSplit()
|
||||
let l:winwidth = g:NERDTreeWinSize
|
||||
endif
|
||||
|
||||
call nerdtree#exec('wincmd p')
|
||||
vnew
|
||||
call nerdtree#exec('wincmd p', 1)
|
||||
call nerdtree#exec('vnew', 1)
|
||||
|
||||
let l:currentWindowNumber = winnr()
|
||||
|
||||
@@ -228,7 +228,7 @@ function! s:Opener._newVSplit()
|
||||
call g:NERDTree.CursorToTreeWin()
|
||||
execute 'silent vertical resize ' . l:winwidth
|
||||
|
||||
call nerdtree#exec(l:currentWindowNumber . 'wincmd w')
|
||||
call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Opener.open(target) {{{1
|
||||
@@ -290,9 +290,9 @@ function! s:Opener._previousWindow()
|
||||
else
|
||||
try
|
||||
if !self._isWindowUsable(winnr("#"))
|
||||
call nerdtree#exec(self._firstUsableWindow() . "wincmd w")
|
||||
call nerdtree#exec(self._firstUsableWindow() . "wincmd w", 1)
|
||||
else
|
||||
call nerdtree#exec('wincmd p')
|
||||
call nerdtree#exec('wincmd p', 1)
|
||||
endif
|
||||
catch /^Vim\%((\a\+)\)\=:E37/
|
||||
call g:NERDTree.CursorToTreeWin()
|
||||
@@ -305,8 +305,8 @@ endfunction
|
||||
|
||||
" FUNCTION: Opener._restoreCursorPos() {{{1
|
||||
function! s:Opener._restoreCursorPos()
|
||||
call nerdtree#exec(self._tabnr . 'tabnext')
|
||||
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w')
|
||||
call nerdtree#exec(self._tabnr . 'tabnext', 1)
|
||||
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w', 1)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Opener._reuseWindow() {{{1
|
||||
@@ -321,7 +321,7 @@ function! s:Opener._reuseWindow()
|
||||
"check the current tab for the window
|
||||
let winnr = bufwinnr('^' . self._path.str() . '$')
|
||||
if winnr != -1
|
||||
call nerdtree#exec(winnr . "wincmd w")
|
||||
call nerdtree#exec(winnr . "wincmd w", 0)
|
||||
call self._checkToCloseTree(0)
|
||||
return 1
|
||||
endif
|
||||
@@ -334,9 +334,9 @@ function! s:Opener._reuseWindow()
|
||||
let tabnr = self._path.tabnr()
|
||||
if tabnr
|
||||
call self._checkToCloseTree(1)
|
||||
call nerdtree#exec(tabnr . 'tabnext')
|
||||
call nerdtree#exec(tabnr . 'tabnext', 1)
|
||||
let winnr = bufwinnr('^' . self._path.str() . '$')
|
||||
call nerdtree#exec(winnr . "wincmd w")
|
||||
call nerdtree#exec(winnr . "wincmd w", 0)
|
||||
return 1
|
||||
endif
|
||||
|
||||
|
||||
@@ -380,7 +380,8 @@ endfunction
|
||||
function! s:Path.getSortOrderIndex()
|
||||
let i = 0
|
||||
while i < len(g:NERDTreeSortOrder)
|
||||
if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
|
||||
if g:NERDTreeSortOrder[i] !~? '\[\[-\?\(timestamp\|size\|extension\)\]\]' &&
|
||||
\ self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
|
||||
return i
|
||||
endif
|
||||
let i = i + 1
|
||||
@@ -407,15 +408,38 @@ endfunction
|
||||
" FUNCTION: Path.getSortKey() {{{1
|
||||
" returns a key used in compare function for sorting
|
||||
function! s:Path.getSortKey()
|
||||
let l:ascending = index(g:NERDTreeSortOrder,'[[timestamp]]')
|
||||
let l:descending = index(g:NERDTreeSortOrder,'[[-timestamp]]')
|
||||
if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder || l:ascending >= 0 || l:descending >= 0
|
||||
let self._sortKey = [self.getSortOrderIndex()]
|
||||
if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder
|
||||
" Look for file metadata tags: [[timestamp]], [[extension]], [[size]]
|
||||
let metadata = []
|
||||
for tag in g:NERDTreeSortOrder
|
||||
if tag =~? '\[\[-\?timestamp\]\]'
|
||||
if self.isDirectory
|
||||
call add(metadata, 0)
|
||||
else
|
||||
call add(metadata, (tag =~ '-' ? -1 : 1) * getftime(self.str()))
|
||||
endif
|
||||
elseif tag =~? '\[\[-\?size\]\]'
|
||||
if self.isDirectory
|
||||
call add(metadata, 0)
|
||||
else
|
||||
call add(metadata, (tag =~ '-' ? -1 : 1) * getfsize(self.str()))
|
||||
endif
|
||||
elseif tag =~? '\[\[extension\]\]'
|
||||
if self.isDirectory
|
||||
call add(metadata, '')
|
||||
else
|
||||
let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$')
|
||||
call add(metadata, extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if l:descending >= 0
|
||||
call insert(self._sortKey, -getftime(self.str()), l:descending == 0 ? 0 : len(self._sortKey))
|
||||
elseif l:ascending >= 0
|
||||
call insert(self._sortKey, getftime(self.str()), l:ascending == 0 ? 0 : len(self._sortKey))
|
||||
if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]'
|
||||
" Apply tags' sorting first if specified first.
|
||||
let self._sortKey = metadata + [self.getSortOrderIndex()]
|
||||
else
|
||||
" Otherwise, do regex grouping first.
|
||||
let self._sortKey = [self.getSortOrderIndex()] + metadata
|
||||
endif
|
||||
|
||||
let path = self.getLastPathComponent(1)
|
||||
|
||||
@@ -340,7 +340,7 @@ function! s:UI.restoreScreenState()
|
||||
if !has_key(self, '_screenState')
|
||||
return
|
||||
endif
|
||||
exec("silent vertical resize " . self._screenState['oldWindowSize'])
|
||||
call nerdtree#exec("silent vertical resize " . self._screenState['oldWindowSize'], 1)
|
||||
|
||||
let old_scrolloff=&scrolloff
|
||||
let &scrolloff=0
|
||||
@@ -360,7 +360,7 @@ function! s:UI.saveScreenState()
|
||||
let self._screenState['oldPos'] = getpos(".")
|
||||
let self._screenState['oldTopLine'] = line("w0")
|
||||
let self._screenState['oldWindowSize']= winwidth("")
|
||||
call nerdtree#exec(win . "wincmd w")
|
||||
call nerdtree#exec(win . "wincmd w", 1)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.setShowHidden(val) {{{1
|
||||
@@ -506,10 +506,10 @@ endfunction
|
||||
function! s:UI.toggleZoom()
|
||||
if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
|
||||
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
|
||||
exec "silent vertical resize ". size
|
||||
call nerdtree#exec("silent vertical resize ". size, 1)
|
||||
let b:NERDTreeZoomed = 0
|
||||
else
|
||||
exec "vertical resize ". get(g:, 'NERDTreeWinSizeMax', '')
|
||||
call nerdtree#exec("vertical resize ". get(g:, 'NERDTreeWinSizeMax', ''), 1)
|
||||
let b:NERDTreeZoomed = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -78,7 +78,7 @@ function! s:inputPrompt(action)
|
||||
endif
|
||||
|
||||
if g:NERDTreeMenuController.isMinimal()
|
||||
call nerdtree#redraw(1) " Clear the menu
|
||||
redraw! " Clear the menu
|
||||
return minimal . " "
|
||||
else
|
||||
let divider = "=========================================================="
|
||||
@@ -114,14 +114,14 @@ function! s:promptToDelBuffer(bufnum, msg)
|
||||
let l:listedBufferCount = 0
|
||||
endif
|
||||
if l:listedBufferCount > 1
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif"
|
||||
call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif", 1)
|
||||
else
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif"
|
||||
call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif", 1)
|
||||
endif
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
call nerdtree#exec("tabnext " . s:originalTabNumber, 1)
|
||||
call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1)
|
||||
" 3. We don't need a previous buffer anymore
|
||||
exec "bwipeout! " . a:bufnum
|
||||
call nerdtree#exec("bwipeout! " . a:bufnum, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -141,17 +141,17 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory)
|
||||
let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'})
|
||||
endif
|
||||
" 1. ensure that a new buffer is loaded
|
||||
exec "badd " . quotedFileName
|
||||
call nerdtree#exec("badd " . quotedFileName, 1)
|
||||
" 2. ensure that all windows which display the just deleted filename
|
||||
" display a buffer for a new filename.
|
||||
let s:originalTabNumber = tabpagenr()
|
||||
let s:originalWindowNumber = winnr()
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif"
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
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(s:originalWindowNumber . "wincmd w", 1)
|
||||
" 3. We don't need a previous buffer anymore
|
||||
try
|
||||
exec "confirm bwipeout " . a:bufNum
|
||||
call nerdtree#exec("confirm bwipeout " . a:bufNum, 0)
|
||||
catch
|
||||
" This happens when answering Cancel if confirmation is needed. Do nothing.
|
||||
endtry
|
||||
@@ -185,7 +185,7 @@ function! NERDTreeAddNode()
|
||||
call newTreeNode.putCursorHere(1, 0)
|
||||
endif
|
||||
|
||||
call nerdtree#redraw(1)
|
||||
redraw!
|
||||
catch /^NERDTree/
|
||||
call nerdtree#echoWarning("Node Not Created.")
|
||||
endtry
|
||||
@@ -234,7 +234,7 @@ function! NERDTreeMoveNode()
|
||||
|
||||
call curNode.putCursorHere(1, 0)
|
||||
|
||||
call nerdtree#redraw(1)
|
||||
redraw!
|
||||
catch /^NERDTree/
|
||||
call nerdtree#echoWarning("Node Not Renamed.")
|
||||
endtry
|
||||
@@ -272,7 +272,7 @@ function! NERDTreeDeleteNode()
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
call nerdtree#redraw(1)
|
||||
redraw!
|
||||
catch /^NERDTree/
|
||||
call nerdtree#echoWarning("Could not remove node")
|
||||
endtry
|
||||
@@ -362,7 +362,7 @@ function! NERDTreeCopyNode()
|
||||
call nerdtree#echo("Copy aborted.")
|
||||
endif
|
||||
let &shellslash = l:shellslash
|
||||
call nerdtree#redraw(1)
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeCopyPath() {{{1
|
||||
|
||||
Reference in New Issue
Block a user