sindrets / diffview.nvim

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

Expand directory intermittently broken #287

Closed asmodeus812 closed 1 year ago

asmodeus812 commented 1 year ago

Hi, i have had this issue for a few months now, seems like whenever i update diffview, on occasion it will break the interoperation with project.nvim. This is due to the fact that what fn.expand . This was working okay until i decided to pull from master recently, seems to be a recent regression. Using fn.expand for the three buffers in the main file diff view reports the following:

Now at some point in the recent past the left side diff panel was working fine, or at least the expand fn was returning valid dir because i have not seen this error (coming from project.nvim trying to set the cwd here- https://github.com/ahmedkhalf/project.nvim/blob/main/lua/project_nvim/project.lua#L180 , since its invalid dir the nvim command fails with an error). Since about a week or so, maybe a bit more, i can see this error again. Saying again because in the past, i have also seen this issue, but it was addressed before i could create an issue.

For example, rolling back to commit e0c8118 works fine, but i can not initially say why, the paths seem nearly identical. The file panel path however does not - diffview:///panels/0 . Seems to work because the on buf_enter event gets triggered only for the right most panel which has the correct path, in newer versions of diffview, bufenter event for some reason gets triggered for the left panel as well, but not for the file panel for example.

Edit: Seems like the buftype property of the older commits for the panel and left commit was populated, but not for the ones in master. https://github.com/ahmedkhalf/project.nvim/blob/main/lua/project_nvim/project.lua#L217 Here is where its decided if the buffer is to be considered.

On e0c8118

On master however

sindrets commented 1 year ago

If project.nvim is automatically changing the cwd based on buffer names, it's that plugin's responsibility to ensure that whatever path it's trying to cd into actually exists. This plugin uses URI's as buffer names for all buffers that do not correspond with a real file on disk. This is conventional.

Edit: Seems like the buftype property of the older commits for the panel and left commit was populated, but not for the ones in master.

Index buffers now have the buftype unset because you can now edit and write said buffers in order to stage changes (see :h diffview-staging).