Improve handling obsolete buffers when renaming or deleting a file via the NERDTree 'm' menu #191

Merged
merged 2 commits into from Oct 18, 2012

4 participants

@ZeusTheTrueGod

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

ZeusTheTrueGod added some commits Aug 26, 2012
@ZeusTheTrueGod ZeusTheTrueGod Better flow for renaming and deleting files
Previously when you delete or moved a file via
md or mm commands the NERDTree was asking you about what to do
with the remaining buffer of the just deleted or moved file. I
always press 'y' in this cases so I've decided to add a new parameter,
NERDTreeAutoDeleteBuffer which you can set to 1 in order to skip
this confirmation.
0a16b24
@ZeusTheTrueGod ZeusTheTrueGod Better handling file renaming and deleting
If you are renaming a file via the mm hotkey and it is already opened then all
tabs and windows containing the old file will be replaced with a
new file. Current tab and windows structure is not changed anymore

If you are deleting a file via the md hotkey and it is already open, i.e.
presents in buffer lists then a buffer will be removed but a window and tab
will be kept with a ':enew' file
6b68797
@twe4ked

@ZeusTheTrueGod this is awesome, any chance of reviewing this @scrooloose?

@scrooloose scrooloose merged commit 3e44d4e into scrooloose:master Oct 18, 2012
@scrooloose
Owner

Sweet, looks good. Cheers :)

@yoran-brault

That's great thanks !

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