CopilotChat.nvim icon indicating copy to clipboard operation
CopilotChat.nvim copied to clipboard

Accept diff is not working on `gitcommit` anymore

Open jiz4oh opened this issue 7 months ago • 1 comments

Hi, thank you create the powerful plugin.

I upgraded the plugin recently and I found the <c-y> is broken on the gitcommit.

My workflow is described below:

  1. open fugitive
  2. call :Git commit to open the gitcommit window
  3. call CopilotChatCommit
  4. call <c-y> to put the commit messages to the gitcommit window

The workflow works fine until I upgrade the plugin.

I try to debug the why and I found the copilot.chat:get_closest_block() return

{
  content = "fix(yarepl): correct aider source syntax property\n\nChanges the configuration property from 'source_func' to 'source_syntax' to \nmatch the expected configuration parameter name in yarepl plugin.",
  end_line = 15,
  header = {
    filename = "code-block",
    filetype = "gitcommit"
  },
  start_line = 12
}

and get_diff return nil.

hope the info can help you

jiz4oh avatar Apr 28 '25 03:04 jiz4oh

I also have this issue

alistairstead avatar May 19 '25 19:05 alistairstead

I am having this issue as well

DanieleFedeli avatar Jul 14 '25 08:07 DanieleFedeli

https://github.com/deathbeam/dotfiles/blob/master/nvim/.config/nvim/lua/config/copilot.lua#L62

you probably need want to do this, for accepting diff you need to have selection with just generic code blocks so the plugin knows the range to replace

deathbeam avatar Jul 30 '25 21:07 deathbeam

thanks @deathbeam

jiz4oh avatar Aug 01 '25 08:08 jiz4oh

@deathbeam this seems to have regressed since the selection changes, and i noticed that you have removed the selection from your config (https://github.com/deathbeam/dotfiles/commit/5b9a8be8a3e983466298054177279e8086a72784) obviously, as it doesnt exist anymore

Is there a new recommened approach?

tris203 avatar Aug 26 '25 18:08 tris203

@deathbeam this seems to have regressed since the selection changes, and i noticed that you have removed the selection from your config (deathbeam/dotfiles@5b9a8be) obviously, as it doesnt exist anymore

Is there a new recommened approach?

Yea was deciding what to do mostly (was considering keybind to replace whole buffer) but just did this for now:

https://github.com/CopilotC-Nvim/CopilotChat.nvim/pull/1370

Now it will out of the box and will try to generate replacement for the buffer

deathbeam avatar Aug 26 '25 18:08 deathbeam

Amazing, thank you for everything!

tris203 avatar Aug 26 '25 18:08 tris203