cocopon/vaffle.vim

Issue when exiting vaffle (do not return to alternate file)

Closed this issue · 9 comments

Hello

I've been using the vaffle vim plugin for 1,5 year now. I've used the commit 07647a4 for quite a long time, as it was working pretty well at this git commit. And I noticed, that after this commit, you made many modifications. And I was not able any more to get something working properly.
My configuration in my .vimrc is as follows:
nmap - :Vaffle %:h
let g:vaffle_force_delete = 1

I open vaffle, while editing a file, using the '-' character. And I use the 'q' character to exit the file explorer and to return to the original file.
But with your last version of the plugin, the 'q' command does no longer work, as it does not return to the original file, but to an empty file.

I found a workaround by replacing my original map command:
nmap - :Vaffle %:h
by:
nmap - :edit %:h

But that's not really satisfactory. Is there a way to fix this issue ?

  • OS: Linux Cent OS 7
  • NVIM v0.4.4

Best regards
Stephane

I'd need the expert opinion of @cocopon but it seems like the current code attempts to get the buffer number of the open buffer at the time one enters vaffle. For whatever reason this is retrieving -1 (in my limited testing) when I 'quit' from vaffle.

I think, with the changes made for keeping the alternate buffer in some other PRs, all 'quit' needs to do is jump to the alternate buffer. I don't think stashing the number of the 'current' buffer is needed...at least not in the case of quitting vaffle.

here's a simple Themis test that demonstrates the problem (I named it copy.vim):

let s:suite = themis#suite('vaffle_e2e_history')
let s:assert = themis#helper('assert')
let s:cwd = getcwd()


function! s:suite.quit_to_original_buffer() abort
  cd test/e2e/files
  " Open file
  e history/foo.txt

  Vaffle
  " quit vaffle
  normal q

  call s:assert.equals(
        \ fnamemodify(bufname('%'), ':t'),
        \ 'foo.txt',
        \ 'Vaffle should have gone back to original buffer')
  
endfunction

I looked into creating a patch to do what seemed like the most obvious way to get this to work (have vaffle#vaffle_quit() use the alternate buffer instead of the stashed buffer). And the test worked. Unfortunately it broke another test: suite.test_duplicate_and_quit in duplication.vim. This set of tests seems to test the situation where Vaffle is run when no other buffers are opened. Therefore there is no alternate file or stashed buffer. In this situation it seems Vaffle expects 'q' to return to an empty buffer with no name. I'm not certain how to do this, but I haven't looked too closely at it yet. And I don't know that I will be able to. Maybe @cocopon will have time.

Hi

Thanks for your investigations. Please let me know when you have a robust patch...
And thank you for this great vaffle plugin, which is really the best file explorer that I've used in vim. Much better than netrw.

Best regards
Stephane

@narcisse82 I created PR #59 a few days ago. Feel free to try it out.

Just merged #59, please try the latest version.

Hi the vaffle team,

I have updated the vaffle plugin to the commit 0a31464. And so far so good. It seems to behave as I would expect.
I have just noticed a small issue in plugin/vaffle.vim:
There's an unnecessary comma at the end of line 24. Could you please delete it ?

I have another request. Maybe people that want to use this wonderful vaffle plugin would like having a little bit more information in the doc section. For instance, in my .vimrc, I have added these lines, which could be interesting:
augroup VimStartup
au!
au VimEnter * if expand("%") == "" && argc() == 0
\ | call vaffle#init('.')
\ | endif
au FileType vaffle setl bufhidden=wipe
augroup END

nmap - :Vaffle %:h

The 1st section allows lauching vaffle when no file argument is given when starting vim / nvim.
The 2nd section (the "-" map command) allows to get a behavior similar to the one defined in the Tim Pope's vinegar plugin.
Do you think that it would be possible to add these lines in doc/vaffle.txt ?

Best regards
Stephane

There's an unnecessary comma at the end of line 24. Could you please delete it ?

Why do you want to delete the comma? It seems to be valid syntax and I prefer that style for the consistency reason:
https://github.com/vim/vim/blob/0289065e41ce3148f929e16a55aa3b161c80576f/runtime/doc/eval.txt#L526

I have another request.

I prefer that one issue has single topic because of the simplicity. If your current problem is solved, please close it first and then create a new issue.

Hi Cocopon
One can consider the issue as resolved. Hence I close this ticket.
Best regards,
Stephane