Description
When set autochdir is enabled, accepting a diff sometimes writes to the wrong file path.
Specifically, when switching folders, the CopilotChat buffer’s working directory does not update correctly, which causes diffs to be applied to the wrong file.
Steps to Reproduce
- Enable
set autochdir in Neovim.
- Open file
~/git/Test/names1.json.
- Open Copilot Chat, run
pwd inside the CopilotChat window → directory is ~/git/Test.
- ✅ Accepting a diff at this point works as expected.
- Now open another file in a different folder (in the original window):
~/git/Test/test/names2.json.
- Run
pwd inside the CopilotChat window → directory is still ~/git/Test (does not change).
- Ask a question in Copilot Chat and accept the diff.
Expected:
The diff should be written to ~/git/Test/test/names2.json.
Actual:
The diff is incorrectly written to ~/git/Test/names1.json.
Environment
NVIM v0.11.3
Build type: RelWithDebInfo
LuaJIT 2.1.1753364724
Run "nvim -V1 -v" for more info
- CopilotChat.nvim version: main/
72216c06fa2ce82406c3406d898a83c02db412a7
- OS: Linux
Additional Notes
- It seems the working directory inside CopilotChat is not updating properly with
autochdir. This causes mismatches between the current buffer path and where diffs are applied. If I disable autochdir in `nvim, everything starts working properly.
- I don't remember when this started being an issue, but this didn't occur at one point.
- Love the plugin... keep up the great work!
Description
When
set autochdiris enabled, accepting a diff sometimes writes to the wrong file path.Specifically, when switching folders, the CopilotChat buffer’s working directory does not update correctly, which causes diffs to be applied to the wrong file.
Steps to Reproduce
set autochdirin Neovim.~/git/Test/names1.json.pwdinside the CopilotChat window → directory is~/git/Test.~/git/Test/test/names2.json.pwdinside the CopilotChat window → directory is still~/git/Test(does not change).Expected:
The diff should be written to
~/git/Test/test/names2.json.Actual:
The diff is incorrectly written to
~/git/Test/names1.json.Environment
72216c06fa2ce82406c3406d898a83c02db412a7Additional Notes
autochdir. This causes mismatches between the current buffer path and where diffs are applied. If I disableautochdirin `nvim, everything starts working properly.