ranger.vim icon indicating copy to clipboard operation
ranger.vim copied to clipboard

Tab feature

Open enthudave opened this issue 7 years ago • 8 comments

Implements the following:

  • Remove the Bclose dependency
  • Fix a bug with the alternate file as described in issue #25
  • Implement a non-default option to see Ranger in a new tab

enthudave avatar Jun 14 '18 18:06 enthudave

mmm, as you know I'm still learning git(hub), that 'review' was meant to accompany commit 91bdf17 about tempname()

enthudave avatar Jun 14 '18 18:06 enthudave

I'm not sure what to do when the user edits a directory but doesn't choose a file. In light of your decision to not consider the directory buffer for the alternate, it means that if a user has:

  1. fileA
  2. fileB
  3. edits a directory
  4. a. does not choose a file
    he should end up with fileB open and fileA being alternate. b. does choose a file
    he should end up with the new file and fileB being alternate

4b is easy, we determine what the alternate buffer is in the directory buffer before opening Ranger, and pass it as a window variable. 4a however I've no idea how to do, the problem is knowing what the alternate buffer was before the user edited a directory. Before they do so, the plugin has no functions running, no way to go back in time to before the new (directory)buffer was created and as a result we have an extra buffer standing between us and an easy way to determine the alternate

enthudave avatar Jun 15 '18 10:06 enthudave

About 4a, I found a neovim function let buffers = nvim_list_bufs() that return the buffer numbers as an array. So I guess the third element should be the fileA: let fileA = nvim_list_bufs()[2].

francoiscabrol avatar Jun 17 '18 16:06 francoiscabrol

I don't think we can rely on the buffer numbers, that would work in this simple example, but I think the buffer numbers do not represent the order in which buffers are visited, only the order in which they were opened, there's a big difference most of the time.

enthudave avatar Jun 17 '18 16:06 enthudave

If there's a function that returns a list of the order in which buffers have been visited for the current session or something that would be exactly what we need

enthudave avatar Jun 17 '18 16:06 enthudave

hum yes I found this PR of fzf https://github.com/junegunn/fzf.vim/commit/852cfa0c11d5661d79ed1faf1cc211b3c6ef7b00#diff-7274b7c6c87526542ef9087f2e997dfaR411 that solve this specific problem of getting the buffers list ordered... but it doesn't look obvious. The related issue is https://github.com/junegunn/fzf.vim/issues/100

francoiscabrol avatar Jun 17 '18 18:06 francoiscabrol

That is quite similar to the workaround I had in my mind, except that I wasn't thinking to use a timestamp, just a window variable (w:old_alternate) to set on BufLeave with that buffer's alternate, so a new buffer in the window can look into that. I just didn't want to have to do this for every BufLeave

enthudave avatar Jun 17 '18 18:06 enthudave

Any plans on merging this @francoiscabrol?

neumachen avatar Feb 16 '19 19:02 neumachen