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
Netrw creating empty hidden buffers when toggling Lexplore with 'set hidden' #1016
Comments
It is wise to contact Dr. Chip directly. His email is at the top of the Yet, when contacting him you should provide and debug it a little:
(Dr. Chip is pretty quick in fixing things, I just made a test with the newest netrw because of your post and noticed that he already fixed an issue I reported less than a month ago) |
Thanks, I tried to find an issue tracker for netrw and couldn't find any. And then I saw some netrw issues opened here so I guessed it was worth a try. This was replicated with no netrw configurations and it's 100% the I'll contact him directly, thanks for taking the time to reply! |
The issue is still there in the latest version of netrw. After skimming the source code, I believe it's because :new is used instead of :split when Lexplore needs to split the window, which creates a new buffer every time. You can fix this yourself in autoload/netrw.vim: search for " new" (including quotes and left-side space). Replace with " split". I've sent Dr. Chip an email. |
Hopefully he implements the fix. |
+1 I'm having this issue too. |
@jototland |
I got a reply. He's looking into it. |
It looks like this hasn't been fixed yet? |
True. I never got any further replies, and had kind of forgotten about it. But I've asked him again. Anyway, the source is there, so it's not that hard to fix oneself, but it shouldn't really be necessary. |
I got a thoughtful reply. My hackish bugfix attempt was not accepted.
That's the end of the story, I guess. If you want NERDTree, you know where to find it. |
Thanks for looking into this and the final update |
From your last comment that you added on, I was wondering if you understood that netrw will not create hidden buffers when :Lex is repeatedly run and quit. I just did it a different way than you had. |
I found this thread because I was looking for a solution to this exact problem. It was disappointing to see there was no configuration tweak to fix this. I've just created a function that clean the unnamed and unchanged buffers (those left overs after hiding Lex) and I decided to share it with you just in case anyone is interested. Create a .vim file to save the function (for example: ~/.vim/explorer.vim) and add the following code: function s:CleanUselessBuffers()
for buf in getbufinfo()
if buf.name == "" && buf.changed == 0 && buf.loaded == 1
:execute ':bdelete ' . buf.bufnr
endif
endfor
endfunction
function s:ToggleLex()
call s:CleanUselessBuffers()
" we iterate through the buffers again because some netrw buffers are
" skipped after we browsed to a different location and hence the name
" of the window changed (no longer '')
let flag = 0
for buf in getbufinfo()
if (get(buf.variables, "current_syntax", "") == "netrwlist") && buf.changed == 0 && buf.loaded == 1
:execute ':bdelete ' . buf.bufnr
let flag = 1
endif
endfor
if !flag
:Lexplore
endif
endfunction
map <Plug>ToggleLex :call <SID>ToggleLex()<CR> And in your ~/.vimrc add the following map (or the one that you prefer): source ~/.vim/explorer.vim
nmap <leader>f <Plug>ToggleLex |
Netrw v161, vim 7.4.2235
When I use
:Lexplore
withset hidden
on my vimrc, every time I use my mapping to toggle off the window, it creates an empty hidden buffer.nnoremap <leader>k :Lexplore<cr>
Just press the mapping a few times to reproduce the issue. It happens in older versions of netrw too (I upgraded to see if there was a fix).
The text was updated successfully, but these errors were encountered: