scrooloose/nerdtree — pull request #191 by ZeusTheTrueGod (2012-08-26 13:37:27+00:00)
Title: Improve handling obsolete buffers when renaming or deleting a file via the NERDTree 'm' menu

I regularly rename and delete files via the NERDTree 'mm' and 'md' shortcuts. The default behaviour for renaming a node is to delete an old buffer. I made a change which replaces the old buffer with a new buffer(the renamed one) which also preserves your current tabs and windows layout. Previously renaming a file from a NERDTree with an active buffer in some window or tab leaded to closing this window or tab if a user agrees to delete the old buffer.

When a file is deleted via the 'md' shortcut I also preserve the windows and tabs layout when a user agrees to delete the old buffer.You see a ':enew' buffer in the window where the just removed file was. This change may be arguable when you have a dedicated tab for the just deleted file, currently it leaves the tab with an empty ':enew' buffer, probably deleting the tab with the only buffer may become a better idea

With this changes it seems quite reasonable to always delete an old buffer thus I've added a new option NERDTreeAutoDeleteBuffer which is turned off by default. When set it is assumed that you answer 'yes' on 'do you want to delete a buffer' or 'do you want to rename a buffer' questions after deleting or moving a node from the NERDTree menu.

I've tested this change with a 'hidden' option enabled and it works quite well in vim 7.3