Skip to content

fix: use absoute path for working tree single-revision diff#433

Open
leisiji wants to merge 1 commit into
esmuellert:mainfrom
leisiji:main
Open

fix: use absoute path for working tree single-revision diff#433
leisiji wants to merge 1 commit into
esmuellert:mainfrom
leisiji:main

Conversation

@leisiji

@leisiji leisiji commented Jul 9, 2026

Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant