You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's probable because of the built-in clang-format formatter (opencode.ai/docs/formatters), do you have a .clang-format config file? Or try disabling it:
I do have a .clang-format but it is almost empty, I work on the llvm project.
I would prefer not to completely disable the formatter, I do want it but I want it to change only the lines that where edited. I see the bot linked to commit that should do this, is there a bug?
The same "feature" It totally bit me and it took me quite a long time after trying all sorts of prompts like:
Make a minimal, surgical change. Do not reformat. Do not adjust spacing, alignment, or line wrapping anywhere else.
Only change the exact lines required for the functional change. If your edit would touch any other line, don't do it.
But then I figured out that it was always actually running clang format on the file.
I agree that this behavior feels like a bug. But, I understand the desire to make the out of the box experience as good as possible.
Perhaps there's a middle ground where opencode looks for uv/ruff/other formatter definitions in pyproject.toml (in the case of python, other appropriate places for other languages), only running the appropriate formatter if it's already configured for the project?
I agree that this behavior feels like a bug. But, I understand the desire to make the out of the box experience as good as possible.
The thing is, I can't think of any project where this behavior is desirable. Sure, if opencode is writing new code, it should format it according to the formatting rules and/or the code it sees around in the same file. But I can't think of any case where I want opencode, after adding a few lines in the middle of the source file, to also move around whitespace in 20 other lines in the same file. Nobody ever wants that...
I agree that, generally, it would obviously be a sane default to only format the code OpenCode writes. But, I can easily imagine a workflow where I want OpenCode apply the same formatting-on-write as my editor.
To me, a large part of this issue is that the UI for this is super misleading, because it'll show you a simple few line change, and it's not until you accept the change that it formats the file and the diff you actually get is very different from the one you accepted.
Activity
github-actions commentedon Jan 14, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
cravenceiling commentedon Jan 16, 2026
It's probable because of the built-in
clang-formatformatter (opencode.ai/docs/formatters), do you have a.clang-formatconfig file? Or try disabling it:{ "$schema": "https://opencode.ai/config.json", "formatter": { "clang-format": { "disabled": true } }, }Adar-Dagan commentedon Jan 19, 2026
I do have a
.clang-formatbut it is almost empty, I work on the llvm project.I would prefer not to completely disable the formatter, I do want it but I want it to change only the lines that where edited. I see the bot linked to commit that should do this, is there a bug?
jasonfharris commentedon Jan 20, 2026
The same "feature" It totally bit me and it took me quite a long time after trying all sorts of prompts like:
Make a minimal, surgical change. Do not reformat. Do not adjust spacing, alignment, or line wrapping anywhere else.
Only change the exact lines required for the functional change. If your edit would touch any other line, don't do it.
But then I figured out that it was always actually running clang format on the file.
mikaelj commentedon Feb 3, 2026
horribly annoying - it's clearly a bug.
prilosac commentedon Feb 19, 2026
I agree that this behavior feels like a bug. But, I understand the desire to make the out of the box experience as good as possible.
Perhaps there's a middle ground where opencode looks for uv/ruff/other formatter definitions in pyproject.toml (in the case of python, other appropriate places for other languages), only running the appropriate formatter if it's already configured for the project?
nyh commentedon Mar 11, 2026
The thing is, I can't think of any project where this behavior is desirable. Sure, if opencode is writing new code, it should format it according to the formatting rules and/or the code it sees around in the same file. But I can't think of any case where I want opencode, after adding a few lines in the middle of the source file, to also move around whitespace in 20 other lines in the same file. Nobody ever wants that...
prilosac commentedon Mar 18, 2026
I agree that, generally, it would obviously be a sane default to only format the code OpenCode writes. But, I can easily imagine a workflow where I want OpenCode apply the same formatting-on-write as my editor.
To me, a large part of this issue is that the UI for this is super misleading, because it'll show you a simple few line change, and it's not until you accept the change that it formats the file and the diff you actually get is very different from the one you accepted.
github-actions commentedon Jul 6, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.