zed
zed copied to clipboard
editor: Apply Copilot suggestion before fixing indent
Release Notes:
- Fixed copilot code not getting accepted when tabbed #4549.
We require contributors to sign our Contributor License Agreement, and we don't have @mmtftr on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
Thanks for the contribution, @mmtftr! Unfortunately, this breaks the previous behavior that caused Zed to only insert the leading whitespace when hitting tab inside of a line's indentation. Can you adjust this PR to fix the issue but also preserve that previous tab behavior?
@as-cii Thanks for the clarification. I don't quite understand the problematic behavior. Is there a test or an issue that I can reference for this behavior? I'd love to write a test to cover this if there isn't any.
EDIT: nvm there are failing tests so I'll check them out
So, is the wanted behavior as so:
- If copilot suggestion has lower indent and we have an active suggestion, accept the copilot suggestion even if we're before suggested indent.
- Otherwise, first indent to suggested indent, accept the suggestion on the next tab.
If this is the case, I'll work on implementing this behavior and adding tests for it.
- Rebased on upstream/main
- Implemented the logic mentioned above
if copilot suggests lower indent than suggested, then avoid auto-indent - Wrote tests according to the requirements mentioned above.
- Also checked locally that the test fails if the editor change is reverted.
@as-cii could you check this one again?
Sorry for the lack of response on this PR.
I am going to close it for now as it conflicts with everything, but I do think this is something we should figure out how to fix. Feel free to re-open and assign me if you're still interested in working on this.