From f8aa749985754091e980c1dc93ec3206ee3dec1f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 14 Jul 2020 07:20:48 -0400 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + lib/nerdtree/ui.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 068646e..f82701c 100644 --- 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 index ed8a248..2ea813c 100644 --- 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