sindrets / diffview.nvim

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

buf_write_post: when diffview was closed, it should not open the diff again #358

Closed wookayin closed 1 year ago

wookayin commented 1 year ago

How to reproduce:

If the diffview window is closed, this is under an user's intention that they would no longer need the diffview (like :DiffviewClose). So the window should not appear again once closed.

Can we make this configurable by any chance?

sindrets commented 1 year ago

The tab pages used for the various views in this plugin should be treated as self contained user interfaces. If you want to do something outside of the interface you need to either fully close it, or go to another tab page. There are only three ways to close these views:

If what you're trying to do is to edit one of the diff entries in its own tab page, you can use the default mapping <C-w>gf to open the local version of the file in a new tab page. If you want a specific mapping that opens a file in a new tab and also closes the view, you can create a custom mapping doing something like this:

function()
  actions.goto_file_tab()
  vim.cmd("tabclose #")
end

I won't implement special logic for guessing when the user no longer deems the tab page to be an interface. It would only complicate things and lead to unpredictable behavior. It would also make it unclear when and how the plugin should run cleanup hooks (closing and releasing LibUV handles, terminating running jobs, restoring local options, deleting buffers, clearing auto commands, etc.). Things that are currently, predictably done on TabClosed.

wookayin commented 1 year ago

Thanks for the detailed feedback.