Compare commits

..

10 Commits
5.3.1 ... 6.1.1

Author SHA1 Message Date
Phil Runninger
2d639b70e7 Catch errors when trying to read CHANGELOG.md. (#1045)
* Catch errors when trying to read CHANGELOG.md.

The ArchLinux package
(https://www.archlinux.org/packages/community/any/vim-nerdtree/) puts
this file in the wrong location.

* Update version number in change log.
2019-10-01 09:17:32 -04:00
Phil Runninger
6318406f66 If file path doesn't exist, :NERDTreeFind its parent directory instead. (#1043)
* If file path doesn't exist, :NERDTreeFind its parent directory instead.

This happens in the following scenario:
```
:edit path/new_file
:NERDTreeFind
```
Instead of an error message about an **invalid path**, this change will
now find the parent directory instead. It will not work if the new file
is **path/new_folder/new_file**, and that's OK because even vim itself
cannot handle both the new folder and the new file; `:w` won't create
the new folder.

* Update version number in change log.

* Change version change from PATCH to MINOR.
2019-09-29 11:28:59 -04:00
Phil Runninger
496b61ead1 Give @dragonxlwang proper credit on PR #1035. 2019-09-26 08:48:57 -04:00
Phil Runninger
5af6859846 Reintroduce necessary variable mistakenly removed. (#1040)
* Reintroduce lost variable: splitMode.

* Add a space between splitMode and "split". `verticalsplit` is invalid.

* Update version number, and add attributions (PR authors)
2019-09-26 08:47:36 -04:00
Phil Runninger
bd744eab8d Make the behavior of window splits consistent (#1035)
* add option to spawn split from previous window

* Update some comments and remove debugging statement.

* Simplify the code, and make it respect NERDTreeWinPos and 'splitbelow'.

* Better logic for getting NERDTree window number when not active window.

* Use common functions for splitting windows. Make splitting respect user.

The placement of split windows now respects the user's choices for the
splitright and splitbelow settings, and the g:NERDTreeWinPos variable.

* Update version number in change log.
2019-09-24 01:19:27 -04:00
Phil Runninger
9193962ad8 Update version number in change log. 2019-09-15 14:44:09 -04:00
Chris Patuzzo
2eaedd8bf4 Fix (p)ath not displaying in the minimal menu (#1038)
The ‘copy (p)ath to clipboard’ menu item was added
recently in this pull request:
https://github.com/scrooloose/nerdtree/pull/1002/files

However, this caused the NERDTreeMinimalMenu to
display ‘copy’ instead of ‘(p)ath’ because it was
simply using the first word of the item’s text.

This change fixes that bug by using a regex to
pick out the first word beginning with ‘(’
2019-09-15 14:41:27 -04:00
Phil Runninger
60ec10b477 Enable events when closing NerdTree window. (#1037)
* Enable events when closing NT window. Triggers updates in Airline.

* Update version number in change log.
2019-09-13 10:49:26 -04:00
Phil Runninger (mac)
51fc75efdb Fix version number. I was on the wrong branch. 2019-09-09 09:40:18 -04:00
Phil Runninger (mac)
79ef87b009 Update version number in change log. 2019-09-09 05:27:48 -04:00
6 changed files with 61 additions and 58 deletions

View File

@@ -1,13 +1,21 @@
# Change Log # Change Log
#### 6.1...
- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045)
- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043)
#### 6.0...
- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040)
- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035)
#### 5.3... #### 5.3...
- **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038)
- **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) - **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037)
- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031)
- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029)
#### 5.2... #### 5.2...
- **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) - **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#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) - **.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) - **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#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) - **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#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) - **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016)
- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015)
- **.3**: Fix `<CR>` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) - **.3**: Fix `<CR>` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014)

View File

@@ -4,9 +4,15 @@ endif
let g:loaded_nerdtree_autoload = 1 let g:loaded_nerdtree_autoload = 1
let s:rootNERDTreePath = resolve(expand("<sfile>:p:h:h")) let s:rootNERDTreePath = resolve(expand("<sfile>:p:h:h"))
"FUNCTION: nerdtree#version(...) {{{1
" If any value is given as an argument, the entire line of text from the
" change log is shown for the current version; otherwise, only the version
" number is shown.
function! nerdtree#version(...) function! nerdtree#version(...)
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
let l:text = 'Unknown' let l:text = 'Unknown'
try
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\+'
@@ -16,12 +22,15 @@ function! nerdtree#version(...)
endif endif
let l:line += 1 let l:line += 1
endwhile endwhile
catch
endtry
return l:text return l:text
endfunction endfunction
" SECTION: General Functions {{{1 " SECTION: General Functions {{{1
"============================================================ "============================================================
"FUNCTION: nerdtree#slash() {{{2
function! nerdtree#slash() function! nerdtree#slash()
if nerdtree#runningWindows() if nerdtree#runningWindows()
@@ -49,7 +58,6 @@ function! nerdtree#and(x,y)
if (l:x % 2) && (l:y % 2) if (l:x % 2) && (l:y % 2)
let l:result += float2nr(pow(2, l:n)) let l:result += float2nr(pow(2, l:n))
endif endif
echomsg l:x . ", " . l:y . " => " l:result
let l:x = float2nr(l:x / 2) let l:x = float2nr(l:x / 2)
let l:y = float2nr(l:y / 2) let l:y = float2nr(l:y / 2)
let l:n += 1 let l:n += 1

View File

@@ -284,6 +284,9 @@ endfunction
" FUNCTION: s:findAndRevealPath(pathStr) {{{1 " FUNCTION: s:findAndRevealPath(pathStr) {{{1
function! s:findAndRevealPath(pathStr) function! s:findAndRevealPath(pathStr)
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
if !filereadable(l:pathStr)
let l:pathStr = fnamemodify(l:pathStr, ':h')
endif
if empty(l:pathStr) if empty(l:pathStr)
call nerdtree#echoWarning('no file for the current buffer') call nerdtree#echoWarning('no file for the current buffer')

View File

@@ -62,9 +62,10 @@ function! s:MenuController._echoPrompt()
if self.isMinimal() if self.isMinimal()
let selection = self.menuItems[self.selection].text let selection = self.menuItems[self.selection].text
let keyword = matchstr(selection, "\([^ ]*")
let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") let shortcuts = map(copy(self.menuItems), "v:val['shortcut']")
let shortcuts[self.selection] = " " . split(selection)[0] . " " let shortcuts[self.selection] = " " . keyword . " "
echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): "
else else

View File

@@ -52,7 +52,7 @@ function! s:NERDTree.Close()
endif endif
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1) call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1)
call nerdtree#exec("close", 1) call nerdtree#exec("close", 0)
if l:useWinId if l:useWinId
call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0) call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0)
else else
@@ -148,12 +148,19 @@ function! s:NERDTree.GetWinNum()
return bufwinnr(t:NERDTreeBufName) return bufwinnr(t:NERDTreeBufName)
endif endif
" If WindowTree, there is no t:NERDTreeBufName variable. Search all windows.
for w in range(1,winnr('$'))
if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$'
return w
endif
endfor
return -1 return -1
endfunction endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1 "FUNCTION: s:NERDTree.IsOpen() {{{1
function! s:NERDTree.IsOpen() function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' return s:NERDTree.GetWinNum() != -1
endfunction endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1 "FUNCTION: s:NERDTree.isTabTree() {{{1

View File

@@ -71,9 +71,9 @@ endfunction
function! s:Opener._gotoTargetWin() function! s:Opener._gotoTargetWin()
if b:NERDTree.isWinTree() if b:NERDTree.isWinTree()
if self._where == 'v' if self._where == 'v'
vsplit call self._newVSplit()
elseif self._where == 'h' elseif self._where == 'h'
split call self._newSplit()
elseif self._where == 't' elseif self._where == 't'
tabnew tabnew
endif endif
@@ -153,44 +153,18 @@ endfunction
" FUNCTION: Opener._newSplit() {{{1 " FUNCTION: Opener._newSplit() {{{1
function! s:Opener._newSplit() function! s:Opener._newSplit()
" Save the user's settings for splitbelow and splitright
let savesplitbelow=&splitbelow
let savesplitright=&splitright
" 'there' will be set to a command to move from the split window
" back to the explorer window
"
" 'back' will be set to a command to move from the explorer window
" back to the newly split window
"
" 'right' and 'below' will be set to the settings needed for
" splitbelow and splitright IF the explorer is the only window.
"
let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l"
let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h"
let right= g:NERDTreeWinPos ==# "left"
let below=0
" Attempt to go to adjacent window
call nerdtree#exec(back, 1)
let onlyOneWin = (winnr("$") ==# 1) let onlyOneWin = (winnr("$") ==# 1)
let savesplitright = &splitright
" If no adjacent window, set splitright and splitbelow appropriately
if onlyOneWin if onlyOneWin
let &splitright=right let &splitright = (g:NERDTreeWinPos ==# "left")
let &splitbelow=below
else
" found adjacent window - invert split direction
let &splitright=!right
let &splitbelow=!below
endif endif
" If only one window (ie. NERDTree), split vertically instead.
let splitMode = onlyOneWin ? "vertical" : "" let splitMode = onlyOneWin ? "vertical" : ""
" Open the new window " Open the new window
try try
exec(splitMode." sp ") call nerdtree#exec('wincmd p', 1)
call nerdtree#exec(splitMode . " split",1)
catch /^Vim\%((\a\+)\)\=:E37/ catch /^Vim\%((\a\+)\)\=:E37/
call g:NERDTree.CursorToTreeWin() call g:NERDTree.CursorToTreeWin()
throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified."
@@ -200,14 +174,12 @@ function! s:Opener._newSplit()
"resize the tree window if no other window was open before "resize the tree window if no other window was open before
if onlyOneWin if onlyOneWin
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
call nerdtree#exec(there, 1) call nerdtree#exec('wincmd p', 1)
exec("silent ". splitMode ." resize ". size) call nerdtree#exec('silent '. splitMode .' resize '. size, 1)
call nerdtree#exec('wincmd p', 0) call nerdtree#exec('wincmd p', 0)
endif endif
" Restore splitmode settings
let &splitbelow=savesplitbelow
let &splitright=savesplitright let &splitright=savesplitright
endfunction endfunction
@@ -215,7 +187,10 @@ endfunction
function! s:Opener._newVSplit() function! s:Opener._newVSplit()
let l:winwidth = winwidth('.') let l:winwidth = winwidth('.')
if winnr('$') == 1 let onlyOneWin = (winnr("$") ==# 1)
let savesplitright = &splitright
if onlyOneWin
let &splitright = (g:NERDTreeWinPos ==# "left")
let l:winwidth = g:NERDTreeWinSize let l:winwidth = g:NERDTreeWinSize
endif endif
@@ -229,6 +204,7 @@ function! s:Opener._newVSplit()
execute 'silent vertical resize ' . l:winwidth execute 'silent vertical resize ' . l:winwidth
call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0) call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0)
let &splitright=savesplitright
endfunction endfunction
" FUNCTION: Opener.open(target) {{{1 " FUNCTION: Opener.open(target) {{{1