vifm / vifm.vim

Vim plugin that allows use of vifm as a file picker
335 stars 19 forks source link

Dangling vifm buffer after :EditVifm #18

Closed randomizedthinking closed 6 years ago

randomizedthinking commented 6 years ago

I use neovim 0.3.1 and the latest version of vifm.vim is installed.

Every time, after using :EditVifm to open a file, the vifm terminal buffer is still dangling around but hidden. One can switch to it manually -- it means all resources are not properly released.

Further into the issue, I found when finish selecting file, the vifm process creates a new buffer with [Process existed 0]. Effectively, the :bdelete command inside callback.on_exit deletes the newly created information buffer, but keeps the vifm terminal buffer dangling around. Not sure whether it is a neovim 0.3.1 only issue.

xaizek commented 6 years ago

As far as I can tell, that's not what's happening. Extra buffer seems to be created here: https://github.com/vifm/vifm.vim/blob/7898fbdd41ee328f6d06e70b46030c85d376b667/plugin/vifm.vim#L108

Per documentation of :file {name}:

If the buffer did have a name, that name becomes the
|alternate-file| name.  An unlisted buffer is created
to hold the old name.

[Process existed 0] appears in the same buffer where vifm was run and :bdelete does close it, however an unlisted one is still there. By that time vifm process is gone (output of pstree confirms that), but term://... name contains enough information to restart it and this is what happens when you switch to it after first vifm buffer is closed (behaviour differs if that one is still around, I just get an error then and unlisted buffer is silently deleted).

Changing the code to this seems to drop that buffer:

        let oldbuf = bufname('%')
        execute 'keepalt file' escape('vifm: '.a:editcmd, ' |')
        execute bufnr(oldbuf).'bwipeout'

And it looks like this should always work.

randomizedthinking commented 6 years ago

Thanks, it works. Now every :EditVifm will increase the buffer# by 2: something we can live with.

randomizedthinking commented 6 years ago

Not sure what this statement is for:

execute 'keepalt file' escape('vifm: '.a:editcmd, ' |')

After removing it, the code still works and won't create the additional hidden buffer.

xaizek commented 6 years ago

:file name changes name of the buffer, otherwise it's very long invocation command of vifm.

See #5. I didn't remember it was your issue. And presence of unloaded buffer is even mentioned there https://github.com/vifm/vifm.vim/issues/5#issuecomment-198509815, looks like I didn't even try to remove it then.

randomizedthinking commented 6 years ago

I see... thanks! Will close the issue now.

Delete the extra unlisted would be good enough.