sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
4k stars 109 forks source link

Diffview switches neovim's tab on close #316

Closed alloc33 closed 1 year ago

alloc33 commented 1 year ago

If I have 2 or more tabs and open diffview while staying, let's say, on tab 1 - when I close diffview it brings me to the next tab (tab 2). Expecting that it will not jumps to the next tab on diffview close. Is this a bug or we can set it up in config?

sindrets commented 1 year ago

and open diffview while staying, let's say, on tab 1

You can't open a diffview while staying on a tab page. Diffview opens in its own tab page.

when I close diffview it brings me to the next tab (tab 2).

This is default behavior for :tabclose. Sounds like what you want is something like:

:tabn # | tabc #
alloc33 commented 1 year ago

@sindrets Here is what I mean. On the video you can see that I have 2 tabs. One tab with rust file buffer and another tab with terminal. If I open current file history from a tab with rust buffer and close it - diffview brings me to the second tab with terminal.

https://user-images.githubusercontent.com/45129790/223770176-eb5558bb-3eaf-4130-bf4b-12e80fe16bc9.mp4

sindrets commented 1 year ago

I understood what you meant. I'm trying to explain that this is default vim behavior with tabs. When you close one tab, vim drops you into the next.

https://user-images.githubusercontent.com/2786478/223794714-a7f5b4ba-7248-42b5-9010-c7382052b5c2.mp4

:DiffviewClose does the same as :tabclose. It only exists for the sake of symmetry with :DiffviewOpen.

Again, it sounds like what you're trying to do is:

" Go to the last accessed tab page (#), then close the diffview 
" (which would at that point be the "last accessed tab page")
:tabn # | tabc #
gegoune commented 1 year ago

Is that correct? Shouldn't it be :tabnext # " go to the last accessed tab page (:tabnext instead of :tab), see :h tabnext?

sindrets commented 1 year ago

@gegoune yes, you're right. My bad, this is what I get for confidently typing out vimscript without testing it first haha :) I'll edit my previous comments.