-
Notifications
You must be signed in to change notification settings - Fork 6k
git: Make permalinks aware of current diffs #41915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Addressing zed-industries#22546, we want git permalinks to be aware of the current changes within the buffer. This change calculates how many lines have been added/deleted between the start and end of the selection and uses those values to offset the selection. This is done within Editor::get_permalink_to_line so that it can be passed to any git_store.
|
Thanks for tackling this! From reading the code, there are a couple of things that need to change:
Here is an approach to this feature that I think should avoid these problems:
This is probably easier to work through live, would you like to pair on it? Link to book a time (I'll be covering the time slots on this Friday): https://cal.com/esther-trapadoux-zed/30min |
|
Thanks for the comments @cole-miller, I've booked in some time to pair on this, looking forward to it. |
|
@cole-miller I've pushed up changes to recalculate this using offsets rather than with row ranges. I've not got to the I thought this was to do with the Would appreciate any insight into any issues you can see here. Thanks! |
b8ae95d to
33dc85c
Compare
|
@siame Thanks for the progress report! I haven't had the chance to run the code and investigate, but if the start value is what you expect and the end value isn't, and you're testing this a selection that covers entire lines, it might just be that the selection includes the trailing newline of the last line? You could confirm by looking at whether the end of the selection looks like |
33dc85c to
d0ecdd1
Compare
|
Thanks for the input @cole-miller, the ranges of the selection are as expected, but I think I've got to the bottom of the issue. In calculating the delta, we're adding the initial size and subtracting the changed size. I added a This is so that we only consider the diff until the end of the selection, as any more than that would be unnecessary. However, we're not doing the same for the There is the function Without scaling the |
|
Hey @siame--thanks for the update. It seems like it might be a bit more natural to do this using a |
Addressing #22546, we want git permalinks to be aware of the current changes within the buffer.
This change calculates how many lines have been added/deleted between the start and end of the selection and uses those values to offset the selection.
This is done within
Editor::get_permalink_to_lineso that it can be passed to any git_store.Example:
Where this selections permalink would previously return L3-L9, it now returns L2-L7.
Release Notes:
Closes #22546
This is my first PR into the zed repository so very happy for any feedback on how I've implemented this. Thanks!