zed icon indicating copy to clipboard operation
zed copied to clipboard

editor: Apply Copilot suggestion before fixing indent

Open mmtftr opened this issue 1 year ago • 7 comments

Release Notes:

  • Fixed copilot code not getting accepted when tabbed #4549.

mmtftr avatar Mar 29 '24 13:03 mmtftr

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[bot] avatar Mar 29 '24 13:03 cla-bot[bot]

@cla-bot check

mmtftr avatar Mar 29 '24 13:03 mmtftr

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Mar 29 '24 13:03 cla-bot[bot]

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 avatar Apr 16 '24 08:04 as-cii

@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

mmtftr avatar Apr 16 '24 10:04 mmtftr

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.

mmtftr avatar Apr 16 '24 16:04 mmtftr

  • 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.

mmtftr avatar Apr 16 '24 18:04 mmtftr

@as-cii could you check this one again?

mmtftr avatar Apr 29 '24 14:04 mmtftr

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.

ConradIrwin avatar Jul 10 '24 18:07 ConradIrwin