-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Smart Selection to FixupRecipe (#1317)
Original PR -> #1083 (Closed because @abeatrix added some really amazing folding range functions to get the resize the selection range) Related Issues -> #585 and #223 ## Problem Summary Currently the selection made by users is not always fully inclusive of the entire range where changes might need to be made by Cody to satisfy the request of fixup by the user. Because we're limiting the changes to only the region that was selected by the user, that creates quite a few problems: 1. Empty Selections don't work( shown by @sqs ) <img width="814" alt="image" src="https://github.com/sourcegraph/cody/assets/11155207/115da45a-b142-4d40-94f5-baf91f2c8a64"> 2. Variable renaming within a function would miss some parts of the function with the original variable name that wasn't selected 4. Bad selection boundaries cause issues with indentation with the changes are applied coz the diffs function doesn't work perfectly in some edge cases 5. Refactors -> If you only selected the return value then any refactor would miss other parts of the function where changes need to be applied 6. Imperfect selection boundaries sometimes lead to repetition of code outside the selection range and sometimes it doesn't generate outputs 7. Hard mode Problem: Its hard to do a mega refactor where change request is on a small selection but that edits multiple files and other places in the codebase to make it all work together in synergy. ## Original solution Originally i leveraged an LLM call to decide the folding range and that was a cool algorithm but it had the latency of an extra LLM call. Now that @abeatrix added some really cool folding range functions I can just leverage them to get a better range for the selection. ## Video ### Before https://github.com/sourcegraph/cody/assets/11155207/53d63ee7-8650-4c03-b935-dfcb64d38c01 https://github.com/sourcegraph/cody/assets/11155207/5ab30335-6c2d-4142-849d-47234d6f4100 ## After https://drive.google.com/file/d/1RVShpNGiWK4wHJW6N_tHEGOdkzSwxM6d/view?usp=sharing ## Test plan <!-- Required. See https://docs.sourcegraph.com/dev/background-information/testing_principles. --> Tested in my local machine a few times. Works perfectly on edge cases too. --------- Co-authored-by: Dominic Cooney <dominic.cooney@gmail.com>
- Loading branch information
1 parent
b280c94
commit 4477ca2
Showing
3 changed files
with
121 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters