Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just updated. Every tab I close shrinks the file explorer to the default width #1176

Closed
4 tasks done
towens opened this issue Sep 25, 2020 · 3 comments · Fixed by #1177
Closed
4 tasks done

Just updated. Every tab I close shrinks the file explorer to the default width #1176

towens opened this issue Sep 25, 2020 · 3 comments · Fixed by #1177

Comments

@towens
Copy link

towens commented Sep 25, 2020

Self-Diagnosis

  • I have searched the issues for an answer to my question.
  • I have reviewed the NERDTree documentation. :h NERDTree
  • I have reviewed the Wiki.
  • I have searched the web for an answer to my question.

State Your Question

Probably a setting... I'm used to shift + A expanding the file explorer and not thinking about it again. Now, any opened tab causes the file explorer to shrink in width to the default.

I didn't go through them all, anything passed tag 5.0.0 seems to exhibit the issue.

@PhilRunninger
Copy link
Member

@towens, you left a lot of context out of your question, so I have to guess how this can be reproduced. Since you mentioned tabs, I assume that you are opening NERDTree, using t to open the selected file in a new tab, and then opening NERDTree again in the new tab. If that assumption is incorrect, please add some more detail to the issue.

Here is what I know/discovered:

  1. The NERDTree buffer's width is remembered each time it closes, so that it can be set to that width when it's opened again. So if you open a file in the same tab, with the o key, the next time NERDTree is opened, it will still be expanded.
  2. Opening NERDTree with the :NERDTree command in a new tab will create a new NERDTree buffer. Since it's new, it will open in the narrow state.
  3. You can use the :NERDTreeMirror command to open the same NERDTree you had in the first tab. This should work, and open it in the expanded state, but there is a bug that I discovered. NERDTree knows the window is supposed to be expanded, but it is being rendered as a narrow window. Pressing A once does nothing, because that is supposed to shrink the window (which is already shrunk). Pressing A the second time expands it.

I will address the bug in the third bullet. If you have another scenario, please describe it in detail in the issue.

@towens
Copy link
Author

towens commented Oct 5, 2020

@PhilRunninger, thanks for bringing up context. I will only have one instance of NERDTree open per tmux session, and you are correct, I open all files by pressing the t key. It's possible my .vimrc is no longer compatible with the latest release. The relevant settings.

" NERDTree
let NERDTreeShowHidden=1
let NERDTreeNaturalSort = 1
set switchbuf=useopen,usetab

" open NERDTree unless you specify a file name
autocmd StdinReadPre * let s:std_in=1 
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif 

@PhilRunninger
Copy link
Member

Your settings are OK, although switchbuf has no effect on what NERDTree does. That setting controls how Quickfix commands work, and NERDTree doesn't use any of those commands.

You also need to add let NERDTreeQuitOnOpen = 1 in order to see the issue I referred to. If set to 0 (the default), NERDTree will unzoom when opening a file so more room is given to the file that was just opened. But when set to 1, NERDTree closes after opening a file, and it remains zoomed the next time it's opened.

To make mirroring the NERDTree in a new tab easier, you can use a mapping like the one below. It will automatically mirror the NERDTree before opening it.

nnoremap <silent> <C-N> :NERDTreeMirror<CR>:NERDTreeFocus<CR>

Checkout branch i1176 and see if it solves your issue. That branch fixes the :NERDTreeMirror command so that it displays an already-zoomed NERDTree correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants