fix: use absoute path for working tree single-revision diff#433
Open
leisiji wants to merge 1 commit into
Open
Conversation
When `:CodeDiff file HEAD` is run on a buffer whose path is outside the current working directory, `handle_git_diff` stored the file path relative to git root as `modified_path`. Later `prepare_buffer` issued `:edit <relative_path>`, which Neovim resolves against cwd — not git root — causing the file to not be found. Use `vim.fn.fnamemodify(current_file, ":p")` to always pass an absolute path when `modified_revision` is "WORKING" (real file), so `:edit` can locate the file regardless of cwd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
:CodeDiff file HEADis run on a buffer whose path is outside the current working directory,handle_git_diffstored the file path relative to git root asmodified_path. Laterprepare_bufferissued:edit <relative_path>, which Neovim resolves against cwd — not git root — causing the file to not be found.Use
vim.fn.fnamemodify(current_file, ":p")to always pass an absolute path whenmodified_revisionis "WORKING" (real file), so:editcan locate the file regardless of cwd.