gemini-cli does not distinguish between $$ and $ when editing files
What happened?
We have two functions in the project $$ and $. $$ returns multiple elements and $ returns a single element. gemini-cli rewrites $$ to $ when making an unrelated change to the file/function containing those.
What did you expect to happen?
I would expect Gemini to keep using $$ and understand that these two are different. It seems to detect this in the text it generated but edits always replace $$ with $.
Client information
$ gemini /about
│ CLI Version 0.1.18 │
│ Git Commit cd7e60e0 │
│ Model gemini-2.5-pro │
│ Sandbox no sandbox │
│ OS darwin │
│ Auth Method gemini-api-key
Login information
API Key
Anything else we need to know?
No response
Hi! I'd like to work on fixing this issue.
My understanding
The problem is in the applyReplacement function in packages/core/src/tools/edit.ts - it uses
replaceAll() without considering character boundaries, causing $$ to be incorrectly matched
when replacing $.
Solution approach
I'll implement boundary-aware string matching that can distinguish between $$ and $ using
precise regex patterns, along with comprehensive tests to prevent regression.
I'll start working on this and submit a PR. Let me know if someone else is already working on it!
Thanks! 🚀
Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.
It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.
Thank you for your contribution!