-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix offset conversions at the end of the document (#2203)
Fixes #2196 ## Changes Conversion of the end of range to offset was buggy. VSC sometimes sends `-1` as line index. If the start or end position of the range is outside the document, the corresponding offset should be set to 0 or the document's text length, respectively. But in case of the end range we were setting it to `0`. To avoid that mistake: * I changed `Position::toOffset` method name to `Position::toOffsetOrZero` to be very explicit of what it does. It should not be used for ranges, but sometimes we only have a single position (like for a text insert). * I added `Range::toOffsetRange` which returns pair of offsets, correcting them appropriately depending if position is a start or end ## Test plan 1. Login to Cody with Free/Pro user 2. Create new empty python file called quicksort.py, make sure it's empty 3. Ask Cody to "create a quicksort function" 4. Click on Apply, make sure code is added to source code file 5. Click on Reject Edit should be properly rejected and file should be empty again.
- Loading branch information
Showing
11 changed files
with
76 additions
and
105 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
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
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
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
Oops, something went wrong.