Skip to content

Conversation

@chanserv
Copy link
Contributor

@chanserv chanserv commented Nov 18, 2025

Description

When I run a keymap to simulate CodeCompanionChat Add in visual mode and with no opened chat buffer, a new buffer is opened and the context (the visual selection) will get added twice to the newly opened buffer (screenshot 1)
This is mainly because the add function will open a new buffer and the routine that open a new buffer will add the context, after that the add function will resume and it will also append the context to the new buffer.

This fix will pass an empty context to the underlying method when opening a new buffer, so no context will be added. After that the context will be handled by add method

Related Issue(s)

N/A

Screenshots

Before

before

After

after

Checklist

  • I've read the contributing guidelines and have adhered to them in this PR
  • I've added test coverage for this fix/feature
  • I've run make all to ensure docs are generated, tests pass and my formatting is applied
  • (optional) I've updated CodeCompanion.has in the init.lua file for my new feature
  • (optional) I've updated the README and/or relevant docs pages

@chanserv chanserv changed the title Update init.lua fix(chat buffer): Fix duplicated context when CodeCompanionChat Add with no opened chat Nov 18, 2025
@chanserv chanserv marked this pull request as ready for review November 18, 2025 22:23
@olimorris olimorris added the P2 Moderate impact, moderate urgency label Nov 18, 2025
@olimorris
Copy link
Owner

Thanks for the PR. Unfortunately this is causing the tests to fail. I think you forgot the brackets

@olimorris olimorris merged commit 14b5782 into olimorris:main Dec 19, 2025
4 checks passed
georgeharker pushed a commit to georgeharker/codecompanion.nvim that referenced this pull request Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Moderate impact, moderate urgency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants