Skip to content
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

Improve diff hunks #18283

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Improve diff hunks #18283

merged 3 commits into from
Sep 24, 2024

Conversation

maxdeviant
Copy link
Member

@maxdeviant maxdeviant commented Sep 24, 2024

This PR improves the display of diff hunks:

  • Deleted hunks now show a regular line indicator in the gutter when expanded
  • The rounding on the diff indicators in the gutter has been removed.

We also did some refactoring to ensure the sizing of the diff indicators in the gutter were consistent.

Collapsed

Screenshot 2024-09-24 at 11 13 26 AM

Expanded

Screenshot 2024-09-24 at 11 13 35 AM

Release Notes:

  • Improved the appearance of diff hunks in the editor.

maxdeviant and others added 2 commits September 24, 2024 11:14
@maxdeviant maxdeviant self-assigned this Sep 24, 2024
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Sep 24, 2024
@@ -90,8 +90,8 @@ pub fn diff_hunk_to_display(
let hunk_end_row = hunk.row_range.end.max(hunk.row_range.start);
let hunk_end_point = Point::new(hunk_end_row.0, 0);

let multi_buffer_start = snapshot.buffer_snapshot.anchor_after(hunk_start_point);
let multi_buffer_end = snapshot.buffer_snapshot.anchor_before(hunk_end_point);
let multi_buffer_start = snapshot.buffer_snapshot.anchor_before(hunk_start_point);
Copy link
Member Author

@maxdeviant maxdeviant Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ran into an issue where when comparing the start points between the diff hunks and the expanded hunks the biases would be different (which was causing problems when comparing them).

Adjusting this line seemed to fix the problem.

@SomeoneToIgnore Do you know if the previous biasing was intentional/load-bearing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely recall taking this pattern from some place, but the old code indeed looks like a mistake to me now.

@maxdeviant maxdeviant merged commit 21be70f into main Sep 24, 2024
9 checks passed
@maxdeviant maxdeviant deleted the improve-diff-hunks branch September 24, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants