commit f8aa749985754091e980c1dc93ec3206ee3dec1f
parent aa37cb40dae26f21a2e343d17ac9f4be9d8bec37
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date: Tue, 14 Jul 2020 07:20:48 -0400
Fix new NERDTrees' width when previous one was in the only window. (#1153)
* Fix new NERDTrees' width when previous one was in the only window.
When leaving a NERDTree buffer, its window's width is remembered so that
that width can be used when showing the buffer again in a new window. If
NERDTree is the only window when leaving the buffer, it remembers the
whole width of the editor. When a new NERDTree window is created, it is
sized such that there is only a very small window for files to be opened
into.
To fix this, if NERDTree is the ONLY window, remember its width as the
value of g:NERDTreeWinSize, not the width of the editor.
* Update version number in change log.
Diffstat:
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -5,6 +5,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
-->
#### 6.9
+- **.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)
- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144)
#### 6.8
diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim
@@ -368,7 +368,7 @@ function! s:UI.saveScreenState()
call g:NERDTree.CursorToTreeWin()
let self._screenState['oldPos'] = getpos('.')
let self._screenState['oldTopLine'] = line('w0')
- let self._screenState['oldWindowSize']= winwidth('')
+ let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('')
call nerdtree#exec(win . 'wincmd w', 1)
catch
endtry