From b4e4adb46f56fb9cc639bab0bb7a30e1ada4441a Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Sat, 31 Aug 2024 03:37:14 +0200 Subject: [PATCH] Use cwd for selection.gitdiff This fixes issue with switching directories after opening neovim. Closes #387 Signed-off-by: Tomas Slusny --- lua/CopilotChat/select.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/select.lua b/lua/CopilotChat/select.lua index e21ea69f..96a07e97 100644 --- a/lua/CopilotChat/select.lua +++ b/lua/CopilotChat/select.lua @@ -161,7 +161,8 @@ function M.gitdiff(source, staged) return nil end - local cmd = 'git diff --no-color --no-ext-diff' .. (staged and ' --staged' or '') + local dir = vim.fn.getcwd() + local cmd = 'git -C ' .. dir .. ' diff --no-color --no-ext-diff' .. (staged and ' --staged' or '') local handle = io.popen(cmd) if not handle then return nil