Compare commits

..

2 Commits
6.1.1 ... 6.1.3

Author SHA1 Message Date
Phil Runninger
53eef21ad6 Save/Set screen state also on WinLeave and WinEnter. (#1048)
* Save/Set screen state also on WinLeave and WinEnter.

The particular use case here is when switching tabs with `gt` and the
NERDTrees have been mirrored.

* Update version number and change log.
2019-10-11 01:04:06 -04:00
Phil Runninger
4fe24d3156 Wrap saveScreenState's statements in a try-catch block. (#1047)
* Wrap saveScreenState's statements in a try-catch block.

If you're in NERDTree, and you press : to open a command line, and then
press Ctrl+F to open the [Command Line] window, you will see errors
related to switching windows while in this function. (Those commands are
not allowed while in the [Command Line] window.) The try-catch block
handles the errors, preventing their being displayed.

* Update version number in change log.
2019-10-08 14:01:50 -04:00
3 changed files with 12 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
# Change Log # Change Log
#### 6.1... #### 6.1...
- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048)
- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047)
- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) - **.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) - **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043)
#### 6.0... #### 6.0...

View File

@@ -355,12 +355,15 @@ endfunction
" scroll position " scroll position
function! s:UI.saveScreenState() function! s:UI.saveScreenState()
let win = winnr() let win = winnr()
call g:NERDTree.CursorToTreeWin()
let self._screenState = {} let self._screenState = {}
try
call g:NERDTree.CursorToTreeWin()
let self._screenState['oldPos'] = getpos(".") let self._screenState['oldPos'] = getpos(".")
let self._screenState['oldTopLine'] = line("w0") let self._screenState['oldTopLine'] = line("w0")
let self._screenState['oldWindowSize']= winwidth("") let self._screenState['oldWindowSize']= winwidth("")
call nerdtree#exec(win . "wincmd w", 1) call nerdtree#exec(win . "wincmd w", 1)
catch
endtry
endfunction endfunction
" FUNCTION: s:UI.setShowHidden(val) {{{1 " FUNCTION: s:UI.setShowHidden(val) {{{1

View File

@@ -170,10 +170,10 @@ call nerdtree#ui_glue#setupCommands()
"============================================================ "============================================================
augroup NERDTree augroup NERDTree
"Save the cursor position whenever we close the nerd tree "Save the cursor position whenever we close the nerd tree
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" exec "autocmd BufLeave,WinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif"
"disallow insert mode in the NERDTree "disallow insert mode in the NERDTree
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" exec "autocmd BufEnter,WinEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
augroup END augroup END
if g:NERDTreeHijackNetrw if g:NERDTreeHijackNetrw